sshauthopt_free:
  205|      2|{
  206|      2|	size_t i;
  207|       |
  208|      2|	if (opts == NULL)
  ------------------
  |  Branch (208:6): [True: 2, False: 0]
  ------------------
  209|      2|		return;
  210|       |
  211|      0|	free(opts->cert_principals);
  212|      0|	free(opts->force_command);
  213|      0|	free(opts->required_from_host_cert);
  214|      0|	free(opts->required_from_host_keys);
  215|       |
  216|      0|	for (i = 0; i < opts->nenv; i++)
  ------------------
  |  Branch (216:14): [True: 0, False: 0]
  ------------------
  217|      0|		free(opts->env[i]);
  218|      0|	free(opts->env);
  219|       |
  220|      0|	for (i = 0; i < opts->npermitopen; i++)
  ------------------
  |  Branch (220:14): [True: 0, False: 0]
  ------------------
  221|      0|		free(opts->permitopen[i]);
  222|      0|	free(opts->permitopen);
  223|       |
  224|      0|	for (i = 0; i < opts->npermitlisten; i++)
  ------------------
  |  Branch (224:14): [True: 0, False: 0]
  ------------------
  225|      0|		free(opts->permitlisten[i]);
  226|      0|	free(opts->permitlisten);
  227|       |
  228|      0|	freezero(opts, sizeof(*opts));
  229|      0|}

auth_log:
  266|    295|{
  267|    295|	Authctxt *authctxt = (Authctxt *)ssh->authctxt;
  268|    295|	int level = SYSLOG_LEVEL_VERBOSE;
  269|    295|	const char *authmsg;
  270|    295|	char *extra = NULL;
  271|       |
  272|    295|	if (!mm_is_monitor() && !authctxt->postponed)
  ------------------
  |  Branch (272:6): [True: 295, False: 0]
  |  Branch (272:26): [True: 295, False: 0]
  ------------------
  273|    295|		return;
  274|       |
  275|       |	/* Raise logging level */
  276|      0|	if (authenticated == 1 ||
  ------------------
  |  Branch (276:6): [True: 0, False: 0]
  ------------------
  277|      0|	    !authctxt->valid ||
  ------------------
  |  Branch (277:6): [True: 0, False: 0]
  ------------------
  278|      0|	    authctxt->failures >= options.max_authtries / 2 ||
  ------------------
  |  Branch (278:6): [True: 0, False: 0]
  ------------------
  279|      0|	    strcmp(method, "password") == 0)
  ------------------
  |  Branch (279:6): [True: 0, False: 0]
  ------------------
  280|      0|		level = SYSLOG_LEVEL_INFO;
  281|       |
  282|      0|	if (authctxt->postponed)
  ------------------
  |  Branch (282:6): [True: 0, False: 0]
  ------------------
  283|      0|		authmsg = "Postponed";
  284|      0|	else if (partial)
  ------------------
  |  Branch (284:11): [True: 0, False: 0]
  ------------------
  285|      0|		authmsg = "Partial";
  286|      0|	else
  287|      0|		authmsg = authenticated ? "Accepted" : "Failed";
  ------------------
  |  Branch (287:13): [True: 0, False: 0]
  ------------------
  288|       |
  289|      0|	if ((extra = format_method_key(authctxt)) == NULL) {
  ------------------
  |  Branch (289:6): [True: 0, False: 0]
  ------------------
  290|      0|		if (authctxt->auth_method_info != NULL)
  ------------------
  |  Branch (290:7): [True: 0, False: 0]
  ------------------
  291|      0|			extra = xstrdup(authctxt->auth_method_info);
  292|      0|	}
  293|       |
  294|      0|	do_log2(level, "%s %s%s%s for %s%.100s from %.200s port %d ssh2%s%s",
  ------------------
  |  |  108|      0|#define do_log2(level, ...)	sshlog(__FILE__, __func__, __LINE__, 0, level, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (108:82): [True: 0, False: 0]
  |  |  |  Branch (108:82): [True: 0, False: 0]
  |  |  |  Branch (108:82): [True: 0, False: 0]
  |  |  |  Branch (108:82): [True: 0, False: 0]
  |  |  |  Branch (108:82): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  295|      0|	    authmsg,
  296|      0|	    method,
  297|      0|	    submethod != NULL ? "/" : "", submethod == NULL ? "" : submethod,
  298|      0|	    authctxt->valid ? "" : "invalid user ",
  299|      0|	    authctxt->user,
  300|      0|	    ssh_remote_ipaddr(ssh),
  301|      0|	    ssh_remote_port(ssh),
  302|      0|	    extra != NULL ? ": " : "",
  303|      0|	    extra != NULL ? extra : "");
  304|       |
  305|      0|	free(extra);
  306|       |
  307|      0|#if defined(CUSTOM_FAILED_LOGIN) || defined(SSH_AUDIT_EVENTS)
  308|      0|	if (authenticated == 0 && !(authctxt->postponed || partial)) {
  ------------------
  |  Branch (308:6): [True: 0, False: 0]
  |  Branch (308:30): [True: 0, False: 0]
  |  Branch (308:53): [True: 0, False: 0]
  ------------------
  309|       |		/* Log failed login attempt */
  310|      0|# ifdef CUSTOM_FAILED_LOGIN
  311|      0|		if (strcmp(method, "password") == 0 ||
  ------------------
  |  Branch (311:7): [True: 0, False: 0]
  ------------------
  312|      0|		    strncmp(method, "keyboard-interactive", 20) == 0 ||
  ------------------
  |  Branch (312:7): [True: 0, False: 0]
  ------------------
  313|      0|		    strcmp(method, "challenge-response") == 0)
  ------------------
  |  Branch (313:7): [True: 0, False: 0]
  ------------------
  314|      0|			record_failed_login(ssh, authctxt->user,
  315|      0|			    auth_get_canonical_hostname(ssh, options.use_dns), "ssh");
  316|      0|# endif
  317|       |# ifdef SSH_AUDIT_EVENTS
  318|       |		audit_event(ssh, audit_classify_auth(method));
  319|       |# endif
  320|      0|	}
  321|      0|#endif
  322|       |#if defined(CUSTOM_FAILED_LOGIN) && defined(WITH_AIXAUTHENTICATE)
  323|       |	if (authenticated)
  324|       |		sys_auth_record_login(authctxt->user,
  325|       |		    auth_get_canonical_hostname(ssh, options.use_dns), "ssh",
  326|       |		    loginmsg);
  327|       |#endif
  328|      0|}
fakepw:
  632|    331|{
  633|    331|	static int done = 0;
  634|    331|	static struct passwd fake;
  635|    331|	const char hashchars[] = "./ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  636|    331|	    "abcdefghijklmnopqrstuvwxyz0123456789"; /* from bcrypt.c */
  637|    331|	char *cp;
  638|       |
  639|    331|	if (done)
  ------------------
  |  Branch (639:6): [True: 330, False: 1]
  ------------------
  640|    330|		return (&fake);
  641|       |
  642|      1|	memset(&fake, 0, sizeof(fake));
  643|      1|	fake.pw_name = "NOUSER";
  644|      1|	fake.pw_passwd = xstrdup("$2a$10$"
  645|      1|	    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
  646|     54|	for (cp = fake.pw_passwd + 7; *cp != '\0'; cp++)
  ------------------
  |  Branch (646:32): [True: 53, False: 1]
  ------------------
  647|     53|		*cp = hashchars[arc4random_uniform(sizeof(hashchars) - 1)];
  648|      1|#ifdef HAVE_STRUCT_PASSWD_PW_GECOS
  649|      1|	fake.pw_gecos = "NOUSER";
  650|      1|#endif
  651|      1|	fake.pw_uid = privsep_pw == NULL ? (uid_t)-1 : privsep_pw->pw_uid;
  ------------------
  |  Branch (651:16): [True: 0, False: 1]
  ------------------
  652|      1|	fake.pw_gid = privsep_pw == NULL ? (gid_t)-1 : privsep_pw->pw_gid;
  ------------------
  |  Branch (652:16): [True: 0, False: 1]
  ------------------
  653|       |#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
  654|       |	fake.pw_class = "";
  655|       |#endif
  656|      1|	fake.pw_dir = "/nonexist";
  657|      1|	fake.pw_shell = "/nonexist";
  658|      1|	done = 1;
  659|       |
  660|      1|	return (&fake);
  661|    331|}

auth2_challenge_stop:
  214|    331|{
  215|    331|	Authctxt *authctxt = ssh->authctxt;
  216|       |	/* unregister callback */
  217|    331|	ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_INFO_RESPONSE, NULL);
  ------------------
  |  |  128|    331|#define SSH2_MSG_USERAUTH_INFO_RESPONSE			61
  ------------------
  218|    331|	if (authctxt->kbdintctxt != NULL) {
  ------------------
  |  Branch (218:6): [True: 0, False: 331]
  ------------------
  219|      0|		kbdint_free(authctxt->kbdintctxt);
  220|       |		authctxt->kbdintctxt = NULL;
  221|      0|	}
  222|    331|}

auth2-hostbased.c:userauth_hostbased:
   61|     13|{
   62|     13|	Authctxt *authctxt = ssh->authctxt;
   63|     13|	struct sshbuf *keyblob = NULL, *b = NULL;
   64|     13|	struct sshkey *key = NULL;
   65|     13|	char *pkalg, *cuser, *chost;
   66|     13|	u_char *sig;
   67|     13|	size_t alen, slen;
   68|     13|	int r, pktype, authenticated = 0;
   69|       |
   70|     13|	if ((r = sshpkt_get_cstring(ssh, &pkalg, &alen)) != 0 ||
  ------------------
  |  Branch (70:6): [True: 2, False: 11]
  ------------------
   71|     11|	    (r = sshpkt_getb_froms(ssh, &keyblob)) != 0 ||
  ------------------
  |  Branch (71:6): [True: 10, False: 1]
  ------------------
   72|      1|	    (r = sshpkt_get_cstring(ssh, &chost, NULL)) != 0 ||
  ------------------
  |  Branch (72:6): [True: 1, False: 0]
  ------------------
   73|      0|	    (r = sshpkt_get_cstring(ssh, &cuser, NULL)) != 0 ||
  ------------------
  |  Branch (73:6): [True: 0, False: 0]
  ------------------
   74|      0|	    (r = sshpkt_get_string(ssh, &sig, &slen)) != 0)
  ------------------
  |  Branch (74:6): [True: 0, False: 0]
  ------------------
   75|     13|		fatal_fr(r, "parse packet");
  ------------------
  |  |  146|     13|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
   76|       |
   77|      0|	debug_f("cuser %s chost %s pkalg %s slen %zu",
  ------------------
  |  |  122|      0|#define debug_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
   78|      0|	    cuser, chost, pkalg, slen);
   79|       |#ifdef DEBUG_PK
   80|       |	debug("signature:");
   81|       |	sshbuf_dump_data(sig, slen, stderr);
   82|       |#endif
   83|      0|	pktype = sshkey_type_from_name(pkalg);
   84|      0|	if (pktype == KEY_UNSPEC) {
  ------------------
  |  Branch (84:6): [True: 0, False: 0]
  ------------------
   85|       |		/* this is perfectly legal */
   86|      0|		logit_f("unsupported public key algorithm: %s",
  ------------------
  |  |  124|      0|#define logit_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
   87|      0|		    pkalg);
   88|      0|		goto done;
   89|      0|	}
   90|      0|	if (match_pattern_list(pkalg,
  ------------------
  |  Branch (90:6): [True: 0, False: 0]
  ------------------
   91|      0|	    options.hostbased_accepted_algos, 0) != 1) {
   92|      0|		logit_f("signature algorithm %s not in "
  ------------------
  |  |  124|      0|#define logit_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
   93|      0|		    "HostbasedAcceptedAlgorithms", pkalg);
   94|      0|		goto done;
   95|      0|	}
   96|      0|	if ((b = sshbuf_fromb(keyblob)) == NULL)
  ------------------
  |  Branch (96:6): [True: 0, False: 0]
  ------------------
   97|      0|		fatal_f("sshbuf_fromb failed");
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
   98|      0|	switch ((r = sshkey_fromb_allowlist(b, &key,
   99|      0|	    options.hostbased_accepted_algos, options.ca_sign_algorithms))) {
  100|      0|	case 0:
  ------------------
  |  Branch (100:2): [True: 0, False: 0]
  ------------------
  101|       |		/* ok */
  102|      0|		break;
  103|      0|	case SSH_ERR_KEY_ALG_UNSUPPORTED:
  ------------------
  |  |   87|      0|#define SSH_ERR_KEY_ALG_UNSUPPORTED		-63
  ------------------
  |  Branch (103:2): [True: 0, False: 0]
  ------------------
  104|       |		/* This shouldn't happen unless the client is being weird */
  105|      0|		logit_f("key algorithm differs from signature algorithm %s and "
  ------------------
  |  |  124|      0|#define logit_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
  106|      0|		    "is not in HostbasedAcceptedAlgorithms", pkalg);
  107|      0|		goto done;
  108|      0|	case SSH_ERR_SIGN_ALG_UNSUPPORTED:
  ------------------
  |  |   82|      0|#define SSH_ERR_SIGN_ALG_UNSUPPORTED		-58
  ------------------
  |  Branch (108:2): [True: 0, False: 0]
  ------------------
  109|      0|		logit_fr(r, "certificate signature algorithm not in "
  ------------------
  |  |  144|      0|#define logit_fr(r, ...)	sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_INFO, ssh_err(r), __VA_ARGS__)
  ------------------
  110|      0|		    "CASignatureAlgorithms");
  111|      0|		goto done;
  112|      0|	default:
  ------------------
  |  Branch (112:2): [True: 0, False: 0]
  ------------------
  113|      0|		error_fr(r, "parse key");
  ------------------
  |  |  145|      0|#define error_fr(r, ...)	sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), __VA_ARGS__)
  ------------------
  114|      0|		goto done;
  115|      0|	}
  116|      0|	sshbuf_free(b);
  117|      0|	b = NULL;
  118|       |
  119|      0|	if (key->type != pktype || (sshkey_type_plain(pktype) == KEY_ECDSA &&
  ------------------
  |  Branch (119:6): [True: 0, False: 0]
  |  Branch (119:30): [True: 0, False: 0]
  ------------------
  120|      0|	    sshkey_ecdsa_nid_from_name(pkalg) != key->ecdsa_nid)) {
  ------------------
  |  Branch (120:6): [True: 0, False: 0]
  ------------------
  121|      0|		error_f("key type mismatch for decoded key "
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  122|      0|		    "(received %s, expected %s)", sshkey_ssh_name(key), pkalg);
  123|      0|		goto done;
  124|      0|	}
  125|      0|	if ((r = sshkey_check_rsa_length(key,
  ------------------
  |  Branch (125:6): [True: 0, False: 0]
  ------------------
  126|      0|	    options.required_rsa_size)) != 0) {
  127|      0|		logit_r(r, "refusing %s key", sshkey_type(key));
  ------------------
  |  |  135|      0|#define logit_r(r, ...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, ssh_err(r), __VA_ARGS__)
  ------------------
  128|      0|		goto done;
  129|      0|	}
  130|       |
  131|      0|	if (!authctxt->valid || authctxt->user == NULL) {
  ------------------
  |  Branch (131:6): [True: 0, False: 0]
  |  Branch (131:26): [True: 0, False: 0]
  ------------------
  132|      0|		debug2_f("disabled because of invalid user");
  ------------------
  |  |  121|      0|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  133|      0|		goto done;
  134|      0|	}
  135|       |
  136|      0|	if ((b = sshbuf_new()) == NULL)
  ------------------
  |  Branch (136:6): [True: 0, False: 0]
  ------------------
  137|      0|		fatal_f("sshbuf_new failed");
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  138|       |	/* reconstruct packet */
  139|      0|	if ((r = sshbuf_put_stringb(b, ssh->kex->session_id)) != 0 ||
  ------------------
  |  Branch (139:6): [True: 0, False: 0]
  ------------------
  140|      0|	    (r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 ||
  ------------------
  |  |  118|      0|#define SSH2_MSG_USERAUTH_REQUEST			50
  ------------------
  |  Branch (140:6): [True: 0, False: 0]
  ------------------
  141|      0|	    (r = sshbuf_put_cstring(b, authctxt->user)) != 0 ||
  ------------------
  |  Branch (141:6): [True: 0, False: 0]
  ------------------
  142|      0|	    (r = sshbuf_put_cstring(b, authctxt->service)) != 0 ||
  ------------------
  |  Branch (142:6): [True: 0, False: 0]
  ------------------
  143|      0|	    (r = sshbuf_put_cstring(b, method)) != 0 ||
  ------------------
  |  Branch (143:6): [True: 0, False: 0]
  ------------------
  144|      0|	    (r = sshbuf_put_string(b, pkalg, alen)) != 0 ||
  ------------------
  |  Branch (144:6): [True: 0, False: 0]
  ------------------
  145|      0|	    (r = sshbuf_put_stringb(b, keyblob)) != 0 ||
  ------------------
  |  Branch (145:6): [True: 0, False: 0]
  ------------------
  146|      0|	    (r = sshbuf_put_cstring(b, chost)) != 0 ||
  ------------------
  |  Branch (146:6): [True: 0, False: 0]
  ------------------
  147|      0|	    (r = sshbuf_put_cstring(b, cuser)) != 0)
  ------------------
  |  Branch (147:6): [True: 0, False: 0]
  ------------------
  148|      0|		fatal_fr(r, "reconstruct packet");
  ------------------
  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
  149|       |#ifdef DEBUG_PK
  150|       |	sshbuf_dump(b, stderr);
  151|       |#endif
  152|       |
  153|      0|	auth2_record_info(authctxt,
  154|      0|	    "client user \"%.100s\", client host \"%.100s\"", cuser, chost);
  155|       |
  156|       |	/* test for allowed key and correct signature */
  157|      0|	authenticated = 0;
  158|      0|	if (mm_hostbased_key_allowed(ssh, authctxt->pw, cuser,
  ------------------
  |  Branch (158:6): [True: 0, False: 0]
  ------------------
  159|      0|	    chost, key) &&
  160|      0|	    mm_sshkey_verify(key, sig, slen,
  ------------------
  |  Branch (160:6): [True: 0, False: 0]
  ------------------
  161|      0|	    sshbuf_ptr(b), sshbuf_len(b), pkalg, ssh->compat, NULL) == 0)
  162|      0|		authenticated = 1;
  163|       |
  164|      0|	auth2_record_key(authctxt, authenticated, key);
  165|      0|done:
  166|       |	debug2_f("authenticated %d", authenticated);
  ------------------
  |  |  121|      0|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  167|      0|	sshkey_free(key);
  168|      0|	sshbuf_free(b);
  169|      0|	sshbuf_free(keyblob);
  170|      0|	free(pkalg);
  171|      0|	free(cuser);
  172|      0|	free(chost);
  173|      0|	free(sig);
  174|      0|	return authenticated;
  175|      0|}

auth2-none.c:userauth_none:
   55|      1|{
   56|      1|	int r;
   57|       |
   58|      1|	none_enabled = 0;
   59|      1|	if ((r = sshpkt_get_end(ssh)) != 0)
  ------------------
  |  Branch (59:6): [True: 0, False: 1]
  ------------------
   60|      0|		fatal_fr(r, "parse packet");
  ------------------
  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
   61|      1|	if (options.permit_empty_passwd && options.password_authentication)
  ------------------
  |  Branch (61:6): [True: 0, False: 1]
  |  Branch (61:37): [True: 0, False: 0]
  ------------------
   62|      0|		return mm_auth_password(ssh, "");
   63|      1|	return (0);
   64|      1|}

auth2-passwd.c:userauth_passwd:
   54|     22|{
   55|     22|	char *password = NULL;
   56|     22|	int authenticated = 0, r;
   57|     22|	u_char change;
   58|     22|	size_t len = 0;
   59|       |
   60|     22|	if ((r = sshpkt_get_u8(ssh, &change)) != 0 ||
  ------------------
  |  Branch (60:6): [True: 1, False: 21]
  ------------------
   61|     21|	    (r = sshpkt_get_cstring(ssh, &password, &len)) != 0 ||
  ------------------
  |  Branch (61:6): [True: 4, False: 17]
  ------------------
   62|     17|	    (change && (r = sshpkt_get_cstring(ssh, NULL, NULL)) != 0) ||
  ------------------
  |  Branch (62:7): [True: 15, False: 2]
  |  Branch (62:17): [True: 6, False: 9]
  ------------------
   63|     13|	    (r = sshpkt_get_end(ssh)) != 0) {
  ------------------
  |  Branch (63:6): [True: 2, False: 9]
  ------------------
   64|     13|		freezero(password, len);
   65|     13|		fatal_fr(r, "parse packet");
  ------------------
  |  |  146|     13|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
   66|     13|	}
   67|       |
   68|      9|	if (change)
  ------------------
  |  Branch (68:6): [True: 8, False: 1]
  ------------------
   69|      8|		logit("password change not supported");
  ------------------
  |  |  113|      8|#define logit(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
   70|      1|	else if (mm_auth_password(ssh, password) == 1)
  ------------------
  |  Branch (70:11): [True: 0, False: 1]
  ------------------
   71|      0|		authenticated = 1;
   72|      9|	freezero(password, len);
   73|      9|	return authenticated;
   74|     22|}

auth2-pubkey.c:userauth_pubkey:
  113|     12|{
  114|     12|	Authctxt *authctxt = ssh->authctxt;
  115|     12|	struct passwd *pw = authctxt->pw;
  116|     12|	struct sshbuf *keyblob = NULL, *b = NULL;
  117|     12|	struct sshkey *key = NULL, *hostkey = NULL;
  118|     12|	char *pkalg = NULL, *userstyle = NULL, *key_s = NULL, *ca_s = NULL;
  119|     12|	char *keystring = NULL;
  120|     12|	u_char *sig = NULL, have_sig;
  121|     12|	size_t slen;
  122|     12|	int hostbound, r, pktype;
  123|     12|	int req_presence = 0, req_verify = 0, authenticated = 0;
  124|     12|	struct sshauthopt *authopts = NULL;
  125|     12|	struct sshkey_sig_details *sig_details = NULL;
  126|       |
  127|     12|	hostbound = strcmp(method, "publickey-hostbound-v00@openssh.com") == 0;
  128|       |
  129|     12|	if ((r = sshpkt_get_u8(ssh, &have_sig)) != 0 ||
  ------------------
  |  Branch (129:6): [True: 1, False: 11]
  ------------------
  130|     11|	    (r = sshpkt_get_cstring(ssh, &pkalg, NULL)) != 0 ||
  ------------------
  |  Branch (130:6): [True: 2, False: 9]
  ------------------
  131|      9|	    (r = sshpkt_getb_froms(ssh, &keyblob)) != 0)
  ------------------
  |  Branch (131:6): [True: 7, False: 2]
  ------------------
  132|     10|		fatal_fr(r, "parse %s packet", method);
  ------------------
  |  |  146|     10|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
  133|       |
  134|       |	/* hostbound auth includes the hostkey offered at initial KEX */
  135|      2|	if (hostbound)
  ------------------
  |  Branch (135:6): [True: 0, False: 2]
  ------------------
  136|      0|		check_hostbound_hostkey(ssh); /* fatals on error */
  137|       |
  138|      2|	if (log_level_get() >= SYSLOG_LEVEL_DEBUG2) {
  ------------------
  |  Branch (138:6): [True: 0, False: 2]
  ------------------
  139|      0|		if ((b = sshbuf_fromb(keyblob)) == NULL)
  ------------------
  |  Branch (139:7): [True: 0, False: 0]
  ------------------
  140|      0|			fatal_f("sshbuf_fromb failed");
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  141|      0|		if ((keystring = sshbuf_dtob64_string(b, 0)) == NULL)
  ------------------
  |  Branch (141:7): [True: 0, False: 0]
  ------------------
  142|      0|			fatal_f("sshbuf_dtob64 failed");
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  143|      0|		debug2_f("%s user %s %s public key %s %s",
  ------------------
  |  |  121|      0|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (121:91): [True: 0, False: 0]
  |  |  |  Branch (121:91): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  144|      0|		    authctxt->valid ? "valid" : "invalid", authctxt->user,
  145|      0|		    have_sig ? "attempting" : "querying", pkalg, keystring);
  146|      0|		sshbuf_free(b);
  147|      0|		b = NULL;
  148|      0|	}
  149|       |
  150|      2|	pktype = sshkey_type_from_name(pkalg);
  151|      2|	if (pktype == KEY_UNSPEC) {
  ------------------
  |  Branch (151:6): [True: 2, False: 0]
  ------------------
  152|       |		/* this is perfectly legal */
  153|      2|		verbose_f("unsupported public key algorithm: %s", pkalg);
  ------------------
  |  |  123|      2|#define verbose_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_VERBOSE, NULL, __VA_ARGS__)
  ------------------
  154|      2|		goto done;
  155|      2|	}
  156|      0|	if (match_pattern_list(pkalg, options.pubkey_accepted_algos, 0) != 1) {
  ------------------
  |  Branch (156:6): [True: 0, False: 0]
  ------------------
  157|      0|		logit_f("signature algorithm %s not in "
  ------------------
  |  |  124|      0|#define logit_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
  158|      0|		    "PubkeyAcceptedAlgorithms", pkalg);
  159|      0|		goto done;
  160|      0|	}
  161|      0|	if ((b = sshbuf_fromb(keyblob)) == NULL)
  ------------------
  |  Branch (161:6): [True: 0, False: 0]
  ------------------
  162|      0|		fatal_f("sshbuf_fromb failed");
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  163|      0|	switch ((r = sshkey_fromb_allowlist(b, &key,
  164|      0|	    options.pubkey_accepted_algos, options.ca_sign_algorithms))) {
  165|      0|	case 0:
  ------------------
  |  Branch (165:2): [True: 0, False: 0]
  ------------------
  166|       |		/* ok */
  167|      0|		break;
  168|      0|	case SSH_ERR_KEY_ALG_UNSUPPORTED:
  ------------------
  |  |   87|      0|#define SSH_ERR_KEY_ALG_UNSUPPORTED		-63
  ------------------
  |  Branch (168:2): [True: 0, False: 0]
  ------------------
  169|       |		/* This shouldn't happen unless the client is being weird */
  170|      0|		logit_f("key algorithm differs from signature algorithm %s and "
  ------------------
  |  |  124|      0|#define logit_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
  171|      0|		    "is not in PubkeyAcceptedAlgorithms", pkalg);
  172|      0|		goto done;
  173|      0|	case SSH_ERR_SIGN_ALG_UNSUPPORTED:
  ------------------
  |  |   82|      0|#define SSH_ERR_SIGN_ALG_UNSUPPORTED		-58
  ------------------
  |  Branch (173:2): [True: 0, False: 0]
  ------------------
  174|      0|		logit_fr(r, "certificate signature algorithm not in "
  ------------------
  |  |  144|      0|#define logit_fr(r, ...)	sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_INFO, ssh_err(r), __VA_ARGS__)
  ------------------
  175|      0|		    "CASignatureAlgorithm");
  176|      0|		goto done;
  177|      0|	default:
  ------------------
  |  Branch (177:2): [True: 0, False: 0]
  ------------------
  178|      0|		error_fr(r, "parse key");
  ------------------
  |  |  145|      0|#define error_fr(r, ...)	sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), __VA_ARGS__)
  ------------------
  179|      0|		goto done;
  180|      0|	}
  181|      0|	sshbuf_free(b);
  182|      0|	b = NULL;
  183|       |
  184|       |	/* USERAUTH_REQUEST signature type should match key's type */
  185|      0|	if (key->type != pktype || (sshkey_type_plain(pktype) == KEY_ECDSA &&
  ------------------
  |  Branch (185:6): [True: 0, False: 0]
  |  Branch (185:30): [True: 0, False: 0]
  ------------------
  186|      0|	    sshkey_ecdsa_nid_from_name(pkalg) != key->ecdsa_nid)) {
  ------------------
  |  Branch (186:6): [True: 0, False: 0]
  ------------------
  187|      0|		error_f("key type mismatch for decoded key "
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  188|      0|		    "(received %s, expected %s)", sshkey_ssh_name(key), pkalg);
  189|      0|		goto done;
  190|      0|	}
  191|      0|	if (auth2_key_already_used(authctxt, key)) {
  ------------------
  |  Branch (191:6): [True: 0, False: 0]
  ------------------
  192|      0|		logit("refusing previously-used %s key", sshkey_type(key));
  ------------------
  |  |  113|      0|#define logit(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
  193|      0|		goto done;
  194|      0|	}
  195|      0|	if ((r = sshkey_check_rsa_length(key,
  ------------------
  |  Branch (195:6): [True: 0, False: 0]
  ------------------
  196|      0|	    options.required_rsa_size)) != 0) {
  197|      0|		logit_r(r, "refusing %s key", sshkey_type(key));
  ------------------
  |  |  135|      0|#define logit_r(r, ...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, ssh_err(r), __VA_ARGS__)
  ------------------
  198|      0|		goto done;
  199|      0|	}
  200|      0|	key_s = format_key(key);
  201|      0|	if (sshkey_is_cert(key))
  ------------------
  |  Branch (201:6): [True: 0, False: 0]
  ------------------
  202|      0|		ca_s = format_key(key->cert->signature_key);
  203|       |
  204|      0|	if (have_sig) {
  ------------------
  |  Branch (204:6): [True: 0, False: 0]
  ------------------
  205|      0|		debug3_f("%s have %s signature for %s%s%s",
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (120:91): [True: 0, False: 0]
  |  |  |  Branch (120:91): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  206|      0|		    method, pkalg, key_s,
  207|      0|		    ca_s == NULL ? "" : " CA ", ca_s == NULL ? "" : ca_s);
  208|      0|		if ((r = sshpkt_get_string(ssh, &sig, &slen)) != 0 ||
  ------------------
  |  Branch (208:7): [True: 0, False: 0]
  ------------------
  209|      0|		    (r = sshpkt_get_end(ssh)) != 0)
  ------------------
  |  Branch (209:7): [True: 0, False: 0]
  ------------------
  210|      0|			fatal_fr(r, "parse signature packet");
  ------------------
  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
  211|      0|		if ((b = sshbuf_new()) == NULL)
  ------------------
  |  Branch (211:7): [True: 0, False: 0]
  ------------------
  212|      0|			fatal_f("sshbuf_new failed");
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  213|      0|		if ((r = sshbuf_put_stringb(b,
  ------------------
  |  Branch (213:7): [True: 0, False: 0]
  ------------------
  214|      0|		    ssh->kex->session_id)) != 0)
  215|      0|			fatal_fr(r, "put session id");
  ------------------
  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
  216|      0|		if (!authctxt->valid || authctxt->user == NULL) {
  ------------------
  |  Branch (216:7): [True: 0, False: 0]
  |  Branch (216:27): [True: 0, False: 0]
  ------------------
  217|      0|			debug2_f("disabled because of invalid user");
  ------------------
  |  |  121|      0|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  218|      0|			goto done;
  219|      0|		}
  220|       |		/* reconstruct packet */
  221|      0|		xasprintf(&userstyle, "%s%s%s", authctxt->user,
  222|      0|		    authctxt->style ? ":" : "",
  ------------------
  |  Branch (222:7): [True: 0, False: 0]
  ------------------
  223|      0|		    authctxt->style ? authctxt->style : "");
  ------------------
  |  Branch (223:7): [True: 0, False: 0]
  ------------------
  224|      0|		if ((r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 ||
  ------------------
  |  |  118|      0|#define SSH2_MSG_USERAUTH_REQUEST			50
  ------------------
  |  Branch (224:7): [True: 0, False: 0]
  ------------------
  225|      0|		    (r = sshbuf_put_cstring(b, userstyle)) != 0 ||
  ------------------
  |  Branch (225:7): [True: 0, False: 0]
  ------------------
  226|      0|		    (r = sshbuf_put_cstring(b, authctxt->service)) != 0 ||
  ------------------
  |  Branch (226:7): [True: 0, False: 0]
  ------------------
  227|      0|		    (r = sshbuf_put_cstring(b, method)) != 0 ||
  ------------------
  |  Branch (227:7): [True: 0, False: 0]
  ------------------
  228|      0|		    (r = sshbuf_put_u8(b, have_sig)) != 0 ||
  ------------------
  |  Branch (228:7): [True: 0, False: 0]
  ------------------
  229|      0|		    (r = sshbuf_put_cstring(b, pkalg)) != 0 ||
  ------------------
  |  Branch (229:7): [True: 0, False: 0]
  ------------------
  230|      0|		    (r = sshbuf_put_stringb(b, keyblob)) != 0)
  ------------------
  |  Branch (230:7): [True: 0, False: 0]
  ------------------
  231|      0|			fatal_fr(r, "reconstruct %s packet", method);
  ------------------
  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
  232|      0|		if (hostbound &&
  ------------------
  |  Branch (232:7): [True: 0, False: 0]
  ------------------
  233|      0|		    (r = sshkey_puts(ssh->kex->initial_hostkey, b)) != 0)
  ------------------
  |  Branch (233:7): [True: 0, False: 0]
  ------------------
  234|      0|			fatal_fr(r, "reconstruct %s packet", method);
  ------------------
  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
  235|       |#ifdef DEBUG_PK
  236|       |		sshbuf_dump(b, stderr);
  237|       |#endif
  238|       |		/* test for correct signature */
  239|      0|		authenticated = 0;
  240|      0|		if (mm_user_key_allowed(ssh, pw, key, 1, &authopts) &&
  ------------------
  |  Branch (240:7): [True: 0, False: 0]
  ------------------
  241|      0|		    mm_sshkey_verify(key, sig, slen,
  ------------------
  |  Branch (241:7): [True: 0, False: 0]
  ------------------
  242|      0|		    sshbuf_ptr(b), sshbuf_len(b),
  243|      0|		    (ssh->compat & SSH_BUG_SIGTYPE) == 0 ? pkalg : NULL,
  ------------------
  |  |   31|      0|#define SSH_BUG_SIGTYPE		0x00000002
  ------------------
  |  Branch (243:7): [True: 0, False: 0]
  ------------------
  244|      0|		    ssh->compat, &sig_details) == 0) {
  245|      0|			authenticated = 1;
  246|      0|		}
  247|      0|		if (authenticated == 1 && sig_details != NULL) {
  ------------------
  |  Branch (247:7): [True: 0, False: 0]
  |  Branch (247:29): [True: 0, False: 0]
  ------------------
  248|      0|			auth2_record_info(authctxt, "signature count = %u",
  249|      0|			    sig_details->sk_counter);
  250|      0|			debug_f("sk_counter = %u, sk_flags = 0x%02x",
  ------------------
  |  |  122|      0|#define debug_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  251|      0|			    sig_details->sk_counter, sig_details->sk_flags);
  252|      0|			req_presence = (options.pubkey_auth_options &
  ------------------
  |  Branch (252:19): [True: 0, False: 0]
  ------------------
  253|      0|			    PUBKEYAUTH_TOUCH_REQUIRED) ||
  ------------------
  |  |   48|      0|#define PUBKEYAUTH_TOUCH_REQUIRED	(1)
  ------------------
  254|      0|			    !authopts->no_require_user_presence;
  ------------------
  |  Branch (254:8): [True: 0, False: 0]
  ------------------
  255|      0|			if (req_presence && (sig_details->sk_flags &
  ------------------
  |  Branch (255:8): [True: 0, False: 0]
  |  Branch (255:24): [True: 0, False: 0]
  ------------------
  256|      0|			    SSH_SK_USER_PRESENCE_REQD) == 0) {
  ------------------
  |  |   25|      0|#define SSH_SK_USER_PRESENCE_REQD	0x01
  ------------------
  257|      0|				error("public key %s signature for %s%s from "
  ------------------
  |  |  114|      0|#define error(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (114:87): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  258|      0|				    "%.128s port %d rejected: user presence "
  259|      0|				    "(authenticator touch) requirement "
  260|      0|				    "not met ", key_s,
  261|      0|				    authctxt->valid ? "" : "invalid user ",
  262|      0|				    authctxt->user, ssh_remote_ipaddr(ssh),
  263|      0|				    ssh_remote_port(ssh));
  264|      0|				authenticated = 0;
  265|      0|				goto done;
  266|      0|			}
  267|      0|			req_verify = (options.pubkey_auth_options &
  ------------------
  |  Branch (267:17): [True: 0, False: 0]
  ------------------
  268|      0|			    PUBKEYAUTH_VERIFY_REQUIRED) ||
  ------------------
  |  |   49|      0|#define PUBKEYAUTH_VERIFY_REQUIRED	(1<<1)
  ------------------
  269|      0|			    authopts->require_verify;
  ------------------
  |  Branch (269:8): [True: 0, False: 0]
  ------------------
  270|      0|			if (req_verify && (sig_details->sk_flags &
  ------------------
  |  Branch (270:8): [True: 0, False: 0]
  |  Branch (270:22): [True: 0, False: 0]
  ------------------
  271|      0|			    SSH_SK_USER_VERIFICATION_REQD) == 0) {
  ------------------
  |  |   26|      0|#define SSH_SK_USER_VERIFICATION_REQD	0x04
  ------------------
  272|      0|				error("public key %s signature for %s%s from "
  ------------------
  |  |  114|      0|#define error(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (114:87): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  273|      0|				    "%.128s port %d rejected: user "
  274|      0|				    "verification requirement not met ", key_s,
  275|      0|				    authctxt->valid ? "" : "invalid user ",
  276|      0|				    authctxt->user, ssh_remote_ipaddr(ssh),
  277|      0|				    ssh_remote_port(ssh));
  278|      0|				authenticated = 0;
  279|      0|				goto done;
  280|      0|			}
  281|      0|		}
  282|      0|		auth2_record_key(authctxt, authenticated, key);
  283|      0|	} else {
  284|      0|		debug_f("%s test pkalg %s pkblob %s%s%s", method, pkalg, key_s,
  ------------------
  |  |  122|      0|#define debug_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (122:90): [True: 0, False: 0]
  |  |  |  Branch (122:90): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  285|      0|		    ca_s == NULL ? "" : " CA ", ca_s == NULL ? "" : ca_s);
  286|       |
  287|      0|		if ((r = sshpkt_get_end(ssh)) != 0)
  ------------------
  |  Branch (287:7): [True: 0, False: 0]
  ------------------
  288|      0|			fatal_fr(r, "parse packet");
  ------------------
  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
  289|       |
  290|       |		/* XXX fake reply and always send PK_OK ? */
  291|       |		/*
  292|       |		 * XXX this allows testing whether a user is allowed
  293|       |		 * to login: if you happen to have a valid pubkey this
  294|       |		 * message is sent. the message is NEVER sent at all
  295|       |		 * if a user is not allowed to login. is this an
  296|       |		 * issue? -markus
  297|       |		 */
  298|      0|		if (authctxt->valid && authctxt->user != NULL &&
  ------------------
  |  Branch (298:7): [True: 0, False: 0]
  |  Branch (298:26): [True: 0, False: 0]
  ------------------
  299|      0|		    mm_user_key_allowed(ssh, pw, key, 0, NULL)) {
  ------------------
  |  Branch (299:7): [True: 0, False: 0]
  ------------------
  300|      0|			if ((r = sshpkt_start(ssh, SSH2_MSG_USERAUTH_PK_OK))
  ------------------
  |  |  125|      0|#define SSH2_MSG_USERAUTH_PK_OK				60
  ------------------
  |  Branch (300:8): [True: 0, False: 0]
  ------------------
  301|      0|			    != 0 ||
  302|      0|			    (r = sshpkt_put_cstring(ssh, pkalg)) != 0 ||
  ------------------
  |  Branch (302:8): [True: 0, False: 0]
  ------------------
  303|      0|			    (r = sshpkt_put_stringb(ssh, keyblob)) != 0 ||
  ------------------
  |  Branch (303:8): [True: 0, False: 0]
  ------------------
  304|      0|			    (r = sshpkt_send(ssh)) != 0 ||
  ------------------
  |  Branch (304:8): [True: 0, False: 0]
  ------------------
  305|      0|			    (r = ssh_packet_write_wait(ssh)) != 0)
  ------------------
  |  Branch (305:8): [True: 0, False: 0]
  ------------------
  306|      0|				fatal_fr(r, "send packet");
  ------------------
  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
  307|      0|			authctxt->postponed = 1;
  308|      0|		} else {
  309|       |			/*
  310|       |			 * NB. invalid users must be accounted for in exactly
  311|       |			 * the same way as valid users whose key was refused,
  312|       |			 * otherwise MaxAuthTries becomes a username oracle.
  313|       |			 */
  314|       |			/*
  315|       |			 * Don't count this as an authentication failure
  316|       |			 * unless we have already used up the separate
  317|       |			 * max-pk-ok budget (if any).
  318|       |			 */
  319|      0|			if (authctxt->pk_ok_failures++ < options.max_pubkey_ok)
  ------------------
  |  Branch (319:8): [True: 0, False: 0]
  ------------------
  320|      0|				authctxt->auth_failure_already_counted = 1;
  321|      0|			debug3_f("pubkey test %d of %d%s",
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (120:91): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  322|      0|			    authctxt->pk_ok_failures, options.max_pubkey_ok,
  323|      0|			    authctxt->auth_failure_already_counted ?
  324|      0|			    "" : ": treating as authentication failure");
  325|      0|		 }
  326|      0|	}
  327|      2|done:
  328|      2|	if (authenticated == 1 && auth_activate_options(ssh, authopts) != 0) {
  ------------------
  |  Branch (328:6): [True: 0, False: 2]
  |  Branch (328:28): [True: 0, False: 0]
  ------------------
  329|      0|		debug_f("key options inconsistent with existing");
  ------------------
  |  |  122|      0|#define debug_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  330|      0|		authenticated = 0;
  331|      0|	}
  332|      2|	debug2_f("authenticated %d pkalg %s", authenticated, pkalg);
  ------------------
  |  |  121|      2|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  333|       |
  334|      2|	sshbuf_free(b);
  335|      2|	sshbuf_free(keyblob);
  336|      2|	sshauthopt_free(authopts);
  337|      2|	sshkey_free(key);
  338|      2|	sshkey_free(hostkey);
  339|      2|	free(keystring);
  340|      2|	free(userstyle);
  341|      2|	free(pkalg);
  342|      2|	free(key_s);
  343|      2|	free(ca_s);
  344|      2|	free(sig);
  345|      2|	sshkey_sig_details_free(sig_details);
  346|      2|	return authenticated;
  347|      0|}

auth_failure_delay:
  270|    293|{
  271|    293|	ensure_minimum_time_since(tstart, user_specific_delay(authctxt->user));
  272|    293|}
userauth_finish:
  371|    295|{
  372|    295|	Authctxt *authctxt = ssh->authctxt;
  373|    295|	Authmethod *m = NULL;
  374|    295|	const char *method = packet_method;
  375|    295|	char *methods;
  376|    295|	int r, partial = 0;
  377|       |
  378|    295|	if (authenticated) {
  ------------------
  |  Branch (378:6): [True: 0, False: 295]
  ------------------
  379|      0|		if (!authctxt->valid) {
  ------------------
  |  Branch (379:7): [True: 0, False: 0]
  ------------------
  380|      0|			fatal("INTERNAL ERROR: authenticated invalid user %s",
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  381|      0|			    authctxt->user);
  382|      0|		}
  383|      0|		if (authctxt->postponed)
  ------------------
  |  Branch (383:7): [True: 0, False: 0]
  ------------------
  384|      0|			fatal("INTERNAL ERROR: authenticated and postponed");
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  385|       |		/* prefer primary authmethod name to possible synonym */
  386|      0|		if ((m = authmethod_byname(method)) == NULL)
  ------------------
  |  Branch (386:7): [True: 0, False: 0]
  ------------------
  387|      0|			fatal("INTERNAL ERROR: bad method %s", method);
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  388|      0|		method = m->cfg->name;
  389|      0|	}
  390|       |
  391|       |	/* Special handling for root */
  392|    295|	if (authenticated && authctxt->pw->pw_uid == 0 &&
  ------------------
  |  Branch (392:6): [True: 0, False: 295]
  |  Branch (392:23): [True: 0, False: 0]
  ------------------
  393|      0|	    !auth_root_allowed(ssh, method)) {
  ------------------
  |  Branch (393:6): [True: 0, False: 0]
  ------------------
  394|      0|		authenticated = 0;
  395|       |#ifdef SSH_AUDIT_EVENTS
  396|       |		mm_audit_event(ssh, SSH_LOGIN_ROOT_DENIED);
  397|       |#endif
  398|      0|	}
  399|       |
  400|    295|	if (authenticated && options.num_auth_methods != 0) {
  ------------------
  |  Branch (400:6): [True: 0, False: 295]
  |  Branch (400:23): [True: 0, False: 0]
  ------------------
  401|      0|		if (!auth2_update_methods_lists(authctxt, method, submethod)) {
  ------------------
  |  Branch (401:7): [True: 0, False: 0]
  ------------------
  402|      0|			authenticated = 0;
  403|      0|			partial = 1;
  404|      0|		}
  405|      0|	}
  406|       |
  407|       |	/* Log before sending the reply */
  408|    295|	auth_log(ssh, authenticated, partial, method, submethod);
  409|       |
  410|       |	/* Update information exposed to session */
  411|    295|	if (authenticated || partial)
  ------------------
  |  Branch (411:6): [True: 0, False: 295]
  |  Branch (411:23): [True: 0, False: 295]
  ------------------
  412|      0|		auth2_update_session_info(authctxt, method, submethod);
  413|       |
  414|    295|	if (authctxt->postponed)
  ------------------
  |  Branch (414:6): [True: 0, False: 295]
  ------------------
  415|      0|		return;
  416|       |
  417|       |#ifdef USE_PAM
  418|       |	if (options.use_pam && authenticated) {
  419|       |		int r, success = mm_do_pam_account();
  420|       |
  421|       |		/* If PAM returned a message, send it to the user. */
  422|       |		if (sshbuf_len(loginmsg) > 0) {
  423|       |			if ((r = sshbuf_put(loginmsg, "\0", 1)) != 0)
  424|       |				fatal("%s: buffer error: %s",
  425|       |				    __func__, ssh_err(r));
  426|       |			userauth_send_banner(ssh, sshbuf_ptr(loginmsg));
  427|       |			if ((r = ssh_packet_write_wait(ssh)) != 0) {
  428|       |				sshpkt_fatal(ssh, r,
  429|       |				    "%s: send PAM banner", __func__);
  430|       |			}
  431|       |		}
  432|       |		if (!success) {
  433|       |			fatal("Access denied for user %s by PAM account "
  434|       |			    "configuration", authctxt->user);
  435|       |		}
  436|       |	}
  437|       |#endif
  438|       |
  439|    295|	if (authenticated == 1) {
  ------------------
  |  Branch (439:6): [True: 0, False: 295]
  ------------------
  440|       |		/* turn off userauth */
  441|      0|		ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_REQUEST,
  ------------------
  |  |  118|      0|#define SSH2_MSG_USERAUTH_REQUEST			50
  ------------------
  442|      0|		    &dispatch_protocol_ignore);
  443|      0|		if ((r = sshpkt_start(ssh, SSH2_MSG_USERAUTH_SUCCESS)) != 0 ||
  ------------------
  |  |  120|      0|#define SSH2_MSG_USERAUTH_SUCCESS			52
  ------------------
  |  Branch (443:7): [True: 0, False: 0]
  ------------------
  444|      0|		    (r = sshpkt_send(ssh)) != 0 ||
  ------------------
  |  Branch (444:7): [True: 0, False: 0]
  ------------------
  445|      0|		    (r = ssh_packet_write_wait(ssh)) != 0)
  ------------------
  |  Branch (445:7): [True: 0, False: 0]
  ------------------
  446|      0|			fatal_fr(r, "send success packet");
  ------------------
  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
  447|       |		/* now we can break out */
  448|      0|		authctxt->success = 1;
  449|      0|		ssh_packet_set_log_preamble(ssh, "user %s", authctxt->user);
  450|    295|	} else {
  451|       |		/* Allow initial try of "none" auth without failure penalty */
  452|    295|		if (!partial && !authctxt->server_caused_failure &&
  ------------------
  |  Branch (452:7): [True: 295, False: 0]
  |  Branch (452:19): [True: 295, False: 0]
  ------------------
  453|    295|		    !authctxt->auth_failure_already_counted &&
  ------------------
  |  Branch (453:7): [True: 295, False: 0]
  ------------------
  454|    295|		    (authctxt->attempt > 1 || strcmp(method, "none") != 0))
  ------------------
  |  Branch (454:8): [True: 0, False: 295]
  |  Branch (454:33): [True: 293, False: 2]
  ------------------
  455|    293|			authctxt->failures++;
  456|    295|		if (authctxt->failures >= options.max_authtries) {
  ------------------
  |  Branch (456:7): [True: 0, False: 295]
  ------------------
  457|       |#ifdef SSH_AUDIT_EVENTS
  458|       |			mm_audit_event(ssh, SSH_LOGIN_EXCEED_MAXTRIES);
  459|       |#endif
  460|      0|			auth_maxtries_exceeded(ssh);
  461|      0|		}
  462|    295|		methods = authmethods_get(authctxt);
  463|    295|		debug3_f("failure partial=%d next methods=\"%s\"",
  ------------------
  |  |  120|    295|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  464|    295|		    partial, methods);
  465|    295|		if ((r = sshpkt_start(ssh, SSH2_MSG_USERAUTH_FAILURE)) != 0 ||
  ------------------
  |  |  119|    295|#define SSH2_MSG_USERAUTH_FAILURE			51
  ------------------
  |  Branch (465:7): [True: 0, False: 295]
  ------------------
  466|    295|		    (r = sshpkt_put_cstring(ssh, methods)) != 0 ||
  ------------------
  |  Branch (466:7): [True: 0, False: 295]
  ------------------
  467|    295|		    (r = sshpkt_put_u8(ssh, partial)) != 0 ||
  ------------------
  |  Branch (467:7): [True: 0, False: 295]
  ------------------
  468|    295|		    (r = sshpkt_send(ssh)) != 0 ||
  ------------------
  |  Branch (468:7): [True: 0, False: 295]
  ------------------
  469|    295|		    (r = ssh_packet_write_wait(ssh)) != 0)
  ------------------
  |  Branch (469:7): [True: 0, False: 295]
  ------------------
  470|      0|			fatal_fr(r, "send failure packet");
  ------------------
  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
  471|    295|		free(methods);
  472|    295|	}
  473|    295|}
auth2_method_allowed:
  483|  1.22k|{
  484|  1.22k|	u_int i;
  485|       |
  486|       |	/*
  487|       |	 * NB. authctxt->num_auth_methods might be zero as a result of
  488|       |	 * auth2_setup_methods_lists(), so check the configuration.
  489|       |	 */
  490|  1.22k|	if (options.num_auth_methods == 0)
  ------------------
  |  Branch (490:6): [True: 1.22k, False: 0]
  ------------------
  491|  1.22k|		return 1;
  492|      0|	for (i = 0; i < authctxt->num_auth_methods; i++) {
  ------------------
  |  Branch (492:14): [True: 0, False: 0]
  ------------------
  493|      0|		if (list_starts_with(authctxt->auth_methods[i], method,
  ------------------
  |  Branch (493:7): [True: 0, False: 0]
  ------------------
  494|      0|		    submethod) != MATCH_NONE)
  ------------------
  |  |   99|      0|#define MATCH_NONE	0	/* method or submethod mismatch */
  ------------------
  495|      0|			return 1;
  496|      0|	}
  497|      0|	return 0;
  498|      0|}
auth2_setup_methods_lists:
  574|    331|{
  575|    331|	u_int i;
  576|       |
  577|       |	/* First, normalise away the "any" pseudo-method */
  578|    331|	if (options.num_auth_methods == 1 &&
  ------------------
  |  Branch (578:6): [True: 0, False: 331]
  ------------------
  579|      0|	    strcmp(options.auth_methods[0], "any") == 0) {
  ------------------
  |  Branch (579:6): [True: 0, False: 0]
  ------------------
  580|      0|		free(options.auth_methods[0]);
  581|      0|		options.auth_methods[0] = NULL;
  582|      0|		options.num_auth_methods = 0;
  583|      0|	}
  584|       |
  585|    331|	if (options.num_auth_methods == 0)
  ------------------
  |  Branch (585:6): [True: 331, False: 0]
  ------------------
  586|    331|		return 0;
  587|      0|	debug3_f("checking methods");
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  588|      0|	authctxt->auth_methods = xcalloc(options.num_auth_methods,
  589|      0|	    sizeof(*authctxt->auth_methods));
  590|      0|	authctxt->num_auth_methods = 0;
  591|      0|	for (i = 0; i < options.num_auth_methods; i++) {
  ------------------
  |  Branch (591:14): [True: 0, False: 0]
  ------------------
  592|      0|		if (auth2_methods_valid(options.auth_methods[i], 1) != 0) {
  ------------------
  |  Branch (592:7): [True: 0, False: 0]
  ------------------
  593|      0|			logit("Authentication methods list \"%s\" contains "
  ------------------
  |  |  113|      0|#define logit(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
  594|      0|			    "disabled method, skipping",
  595|      0|			    options.auth_methods[i]);
  596|      0|			continue;
  597|      0|		}
  598|      0|		debug("authentication methods list %d: %s",
  ------------------
  |  |  111|      0|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  599|      0|		    authctxt->num_auth_methods, options.auth_methods[i]);
  600|      0|		authctxt->auth_methods[authctxt->num_auth_methods++] =
  601|      0|		    xstrdup(options.auth_methods[i]);
  602|      0|	}
  603|      0|	if (authctxt->num_auth_methods == 0) {
  ------------------
  |  Branch (603:6): [True: 0, False: 0]
  ------------------
  604|      0|		error("No AuthenticationMethods left after eliminating "
  ------------------
  |  |  114|      0|#define error(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  605|      0|		    "disabled methods");
  606|      0|		return -1;
  607|      0|	}
  608|      0|	return 0;
  609|      0|}
auth2_authctxt_reset_info:
  696|    331|{
  697|    331|	sshkey_free(authctxt->auth_method_key);
  698|    331|	free(authctxt->auth_method_info);
  699|    331|	authctxt->auth_method_key = NULL;
  700|       |	authctxt->auth_method_info = NULL;
  701|    331|}
sshd_auth_session_fuzz_helper.c:input_userauth_request:
  276|    406|{
  277|    406|	Authctxt *authctxt = ssh->authctxt;
  278|    406|	Authmethod *m = NULL;
  279|    406|	char *user = NULL, *service = NULL, *method = NULL, *style = NULL;
  280|    406|	int r, authenticated = 0;
  281|    406|	double tstart = monotime_double();
  282|       |
  283|    406|	if (authctxt == NULL)
  ------------------
  |  Branch (283:6): [True: 0, False: 406]
  ------------------
  284|      0|		fatal("input_userauth_request: no authctxt");
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  285|       |
  286|    406|	if ((r = sshpkt_get_cstring(ssh, &user, NULL)) != 0 ||
  ------------------
  |  Branch (286:6): [True: 62, False: 344]
  ------------------
  287|    344|	    (r = sshpkt_get_cstring(ssh, &service, NULL)) != 0 ||
  ------------------
  |  Branch (287:6): [True: 8, False: 336]
  ------------------
  288|    336|	    (r = sshpkt_get_cstring(ssh, &method, NULL)) != 0)
  ------------------
  |  Branch (288:6): [True: 5, False: 331]
  ------------------
  289|     75|		goto out;
  290|    331|	debug("userauth-request for user %s service %s method %s", user, service, method);
  ------------------
  |  |  111|    331|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  291|    331|	debug("attempt %d failures %d", authctxt->attempt, authctxt->failures);
  ------------------
  |  |  111|    331|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  292|       |
  293|    331|	if ((style = strchr(user, ':')) != NULL)
  ------------------
  |  Branch (293:6): [True: 3, False: 328]
  ------------------
  294|      3|		*style++ = 0;
  295|       |
  296|    331|	if (authctxt->attempt >= 1024)
  ------------------
  |  Branch (296:6): [True: 0, False: 331]
  ------------------
  297|      0|		auth_maxtries_exceeded(ssh);
  298|    331|	if (authctxt->attempt++ == 0) {
  ------------------
  |  Branch (298:6): [True: 331, False: 0]
  ------------------
  299|       |		/* setup auth context */
  300|    331|		authctxt->pw = mm_getpwnamallow(ssh, user);
  301|    331|		authctxt->user = xstrdup(user);
  302|    331|		authctxt->service = xstrdup(service);
  303|    331|		authctxt->style = style ? xstrdup(style) : NULL;
  ------------------
  |  Branch (303:21): [True: 3, False: 328]
  ------------------
  304|    331|		if (authctxt->pw && strcmp(service, "ssh-connection")==0) {
  ------------------
  |  Branch (304:7): [True: 331, False: 0]
  |  Branch (304:23): [True: 0, False: 331]
  ------------------
  305|      0|			authctxt->valid = 1;
  306|      0|			debug2_f("setting up authctxt for %s", user);
  ------------------
  |  |  121|      0|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  307|    331|		} else {
  308|    331|			authctxt->valid = 0;
  309|       |			/* Invalid user, fake password information */
  310|    331|			authctxt->pw = fakepw();
  311|       |#ifdef SSH_AUDIT_EVENTS
  312|       |			mm_audit_event(ssh, SSH_INVALID_USER);
  313|       |#endif
  314|    331|		}
  315|       |#ifdef USE_PAM
  316|       |		if (options.use_pam)
  317|       |			mm_start_pam(ssh);
  318|       |#endif
  319|    331|		ssh_packet_set_log_preamble(ssh, "%suser %s",
  320|    331|		    authctxt->valid ? "authenticating " : "invalid ", user);
  ------------------
  |  Branch (320:7): [True: 0, False: 331]
  ------------------
  321|    331|		setproctitle("%s [net]", authctxt->valid ? user : "unknown");
  ------------------
  |  Branch (321:28): [True: 0, False: 331]
  ------------------
  322|    331|		mm_inform_authserv(service, style);
  323|    331|		userauth_banner(ssh);
  324|    331|		if ((r = kex_server_update_ext_info(ssh)) != 0)
  ------------------
  |  Branch (324:7): [True: 0, False: 331]
  ------------------
  325|      0|			fatal_fr(r, "kex_server_update_ext_info failed");
  ------------------
  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
  326|    331|		if (auth2_setup_methods_lists(authctxt) != 0)
  ------------------
  |  Branch (326:7): [True: 0, False: 331]
  ------------------
  327|      0|			ssh_packet_disconnect(ssh,
  328|      0|			    "no authentication methods enabled");
  329|    331|	} else if (strcmp(user, authctxt->user) != 0 ||
  ------------------
  |  Branch (329:13): [True: 0, False: 0]
  ------------------
  330|      0|	    strcmp(service, authctxt->service) != 0) {
  ------------------
  |  Branch (330:6): [True: 0, False: 0]
  ------------------
  331|      0|		ssh_packet_disconnect(ssh, "Change of username or service "
  332|      0|		    "not allowed: (%s,%s) -> (%s,%s)",
  333|      0|		    authctxt->user, authctxt->service, user, service);
  334|      0|	}
  335|       |	/* reset state */
  336|    331|	auth2_challenge_stop(ssh);
  337|       |
  338|       |#ifdef GSSAPI
  339|       |	ssh_gssapi_cleanup_global_client();
  340|       |	/* XXX move to auth2_gssapi_stop() */
  341|       |	ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL);
  342|       |	ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE, NULL);
  343|       |#endif
  344|       |
  345|    331|	auth2_authctxt_reset_info(authctxt);
  346|    331|	authctxt->postponed = 0;
  347|    331|	authctxt->server_caused_failure = 0;
  348|    331|	authctxt->auth_failure_already_counted = 0;
  349|       |
  350|       |	/* try to authenticate user */
  351|    331|	m = authmethod_lookup(authctxt, method);
  352|    331|	if (m != NULL && authctxt->failures < options.max_authtries) {
  ------------------
  |  Branch (352:6): [True: 48, False: 283]
  |  Branch (352:19): [True: 48, False: 0]
  ------------------
  353|     48|		debug2("input_userauth_request: try method %s", method);
  ------------------
  |  |  110|     48|#define debug2(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  354|     48|		authenticated =	m->userauth(ssh, method);
  355|     48|	}
  356|    331|	if (!authctxt->authenticated && strcmp(method, "none") != 0)
  ------------------
  |  Branch (356:6): [True: 295, False: 36]
  |  Branch (356:34): [True: 293, False: 2]
  ------------------
  357|    293|		auth_failure_delay(authctxt, tstart);
  358|       |
  359|    331|	userauth_finish(ssh, authenticated, method, NULL);
  360|    331|	r = 0;
  361|    370| out:
  362|    370|	free(service);
  363|    370|	free(user);
  364|    370|	free(method);
  365|    370|	return r;
  366|    331|}
sshd_auth_session_fuzz_helper.c:userauth_banner:
  153|    331|{
  154|    331|	char *banner = NULL;
  155|       |
  156|    331|	if (options.banner == NULL)
  ------------------
  |  Branch (156:6): [True: 331, False: 0]
  ------------------
  157|    331|		return;
  158|       |
  159|      0|	if ((banner = mm_auth2_read_banner()) == NULL)
  ------------------
  |  Branch (159:6): [True: 0, False: 0]
  ------------------
  160|      0|		goto done;
  161|      0|	userauth_send_banner(ssh, banner);
  162|       |
  163|      0|done:
  164|      0|	free(banner);
  165|      0|}
sshd_auth_session_fuzz_helper.c:authmethod_lookup:
  547|    331|{
  548|    331|	Authmethod *method;
  549|       |
  550|    331|	if ((method = authmethod_byname(name)) == NULL)
  ------------------
  |  Branch (550:6): [True: 282, False: 49]
  ------------------
  551|    282|		return NULL;
  552|       |
  553|     49|	if (method->cfg->enabled == NULL || *(method->cfg->enabled) == 0) {
  ------------------
  |  Branch (553:6): [True: 0, False: 49]
  |  Branch (553:38): [True: 1, False: 48]
  ------------------
  554|      1|		debug3_f("method %s not enabled", name);
  ------------------
  |  |  120|      1|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  555|      1|		return NULL;
  556|      1|	}
  557|     48|	if (!auth2_method_allowed(authctxt, method->cfg->name, NULL)) {
  ------------------
  |  Branch (557:6): [True: 0, False: 48]
  ------------------
  558|      0|		debug3_f("method %s not allowed "
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  559|      0|		    "by AuthenticationMethods", name);
  560|      0|		return NULL;
  561|      0|	}
  562|     48|	return method;
  563|     48|}
sshd_auth_session_fuzz_helper.c:ensure_minimum_time_since:
  247|    293|{
  248|    293|	struct timespec ts;
  249|    293|	double elapsed = monotime_double() - start, req = seconds, remain;
  250|       |
  251|    293|	if (elapsed > MAX_FAIL_DELAY_SECONDS) {
  ------------------
  |  |  225|    293|#define MAX_FAIL_DELAY_SECONDS 5.0
  ------------------
  |  Branch (251:6): [True: 0, False: 293]
  ------------------
  252|      0|		debug3_f("elapsed %0.3lfms exceeded the max delay "
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  253|      0|		    "requested %0.3lfms)", elapsed*1000, req*1000);
  254|      0|		return;
  255|      0|	}
  256|       |
  257|       |	/* if we've already passed the requested time, scale up */
  258|    293|	while ((remain = seconds - elapsed) < 0.0)
  ------------------
  |  Branch (258:9): [True: 0, False: 293]
  ------------------
  259|      0|		seconds *= 2;
  260|       |
  261|    293|	ts.tv_sec = remain;
  262|    293|	ts.tv_nsec = (remain - ts.tv_sec) * 1000000000;
  263|    293|	debug3_f("elapsed %0.3lfms, delaying %0.3lfms (requested %0.3lfms)",
  ------------------
  |  |  120|    293|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  264|    293|	    elapsed*1000, remain*1000, req*1000);
  265|       |	nanosleep(&ts, NULL);
  266|    293|}
sshd_auth_session_fuzz_helper.c:user_specific_delay:
  228|    293|{
  229|    293|	char b[512];
  230|    293|	size_t len = ssh_digest_bytes(SSH_DIGEST_SHA512);
  ------------------
  |  |   29|    293|#define SSH_DIGEST_SHA512	4
  ------------------
  231|    293|	u_char *hash = xmalloc(len);
  232|    293|	double delay;
  233|       |
  234|    293|	(void)snprintf(b, sizeof b, "%llu%s",
  235|    293|	    (unsigned long long)options.timing_secret, user);
  236|    293|	if (ssh_digest_memory(SSH_DIGEST_SHA512, b, strlen(b), hash, len) != 0)
  ------------------
  |  |   29|    293|#define SSH_DIGEST_SHA512	4
  ------------------
  |  Branch (236:6): [True: 0, False: 293]
  ------------------
  237|      0|		fatal_f("ssh_digest_memory");
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  238|       |	/* 0-4.2 ms of delay */
  239|    293|	delay = (double)PEEK_U32(hash) / 1000 / 1000 / 1000 / 1000;
  ------------------
  |  |  351|    293|	(((uint32_t)(((const u_char *)(p))[0]) << 24) | \
  |  |  352|    293|	 ((uint32_t)(((const u_char *)(p))[1]) << 16) | \
  |  |  353|    293|	 ((uint32_t)(((const u_char *)(p))[2]) << 8) | \
  |  |  354|    293|	  (uint32_t)(((const u_char *)(p))[3]))
  ------------------
  240|    293|	freezero(hash, len);
  241|    293|	debug3_f("user specific delay %0.3lfms", delay*1000);
  ------------------
  |  |  120|    293|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  242|    293|	return MIN_FAIL_DELAY_SECONDS + delay;
  ------------------
  |  |  224|    293|#define MIN_FAIL_DELAY_SECONDS 0.005
  ------------------
  243|    293|}
sshd_auth_session_fuzz_helper.c:authmethods_get:
  502|    295|{
  503|    295|	struct sshbuf *b;
  504|    295|	char *list;
  505|    295|	int i, r;
  506|       |
  507|    295|	if ((b = sshbuf_new()) == NULL)
  ------------------
  |  Branch (507:6): [True: 0, False: 295]
  ------------------
  508|      0|		fatal_f("sshbuf_new failed");
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  509|  1.77k|	for (i = 0; authmethods[i] != NULL; i++) {
  ------------------
  |  Branch (509:14): [True: 1.47k, False: 295]
  ------------------
  510|  1.47k|		if (strcmp(authmethods[i]->cfg->name, "none") == 0)
  ------------------
  |  Branch (510:7): [True: 295, False: 1.18k]
  ------------------
  511|    295|			continue;
  512|  1.18k|		if (authmethods[i]->cfg->enabled == NULL ||
  ------------------
  |  Branch (512:7): [True: 0, False: 1.18k]
  ------------------
  513|  1.18k|		    *(authmethods[i]->cfg->enabled) == 0)
  ------------------
  |  Branch (513:7): [True: 0, False: 1.18k]
  ------------------
  514|      0|			continue;
  515|  1.18k|		if (!auth2_method_allowed(authctxt, authmethods[i]->cfg->name,
  ------------------
  |  Branch (515:7): [True: 0, False: 1.18k]
  ------------------
  516|  1.18k|		    NULL))
  517|      0|			continue;
  518|  1.18k|		if ((r = sshbuf_putf(b, "%s%s", sshbuf_len(b) ? "," : "",
  ------------------
  |  Branch (518:7): [True: 0, False: 1.18k]
  |  Branch (518:35): [True: 885, False: 295]
  ------------------
  519|  1.18k|		    authmethods[i]->cfg->name)) != 0)
  520|      0|			fatal_fr(r, "buffer error");
  ------------------
  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  ------------------
  521|  1.18k|	}
  522|    295|	if ((list = sshbuf_dup_string(b)) == NULL)
  ------------------
  |  Branch (522:6): [True: 0, False: 295]
  ------------------
  523|      0|		fatal_f("sshbuf_dup_string failed");
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  524|    295|	sshbuf_free(b);
  525|    295|	return list;
  526|    295|}
sshd_auth_session_fuzz_helper.c:authmethod_byname:
  530|    331|{
  531|    331|	int i;
  532|       |
  533|    331|	if (name == NULL)
  ------------------
  |  Branch (533:6): [True: 0, False: 331]
  ------------------
  534|      0|		fatal_f("NULL authentication method name");
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  535|  1.84k|	for (i = 0; authmethods[i] != NULL; i++) {
  ------------------
  |  Branch (535:14): [True: 1.56k, False: 282]
  ------------------
  536|  1.56k|		if (strcmp(name, authmethods[i]->cfg->name) == 0 ||
  ------------------
  |  Branch (536:7): [True: 49, False: 1.51k]
  ------------------
  537|  1.51k|		    (authmethods[i]->cfg->synonym != NULL &&
  ------------------
  |  Branch (537:8): [True: 317, False: 1.20k]
  ------------------
  538|    317|		    strcmp(name, authmethods[i]->cfg->synonym) == 0))
  ------------------
  |  Branch (538:7): [True: 0, False: 317]
  ------------------
  539|     49|			return authmethods[i];
  540|  1.56k|	}
  541|    282|	debug_f("unrecognized authentication method name: %s", name);
  ------------------
  |  |  122|    282|#define debug_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  542|       |	return NULL;
  543|    331|}

cipher_alg_list:
  117|      1|{
  118|      1|	char *ret = NULL;
  119|      1|	const struct sshcipher *c;
  120|      1|	char sep_str[2] = {sep, '\0'};
  121|       |
  122|     12|	for (c = ciphers; c->name != NULL; c++) {
  ------------------
  |  Branch (122:20): [True: 11, False: 1]
  ------------------
  123|     11|		if ((c->flags & CFLAG_INTERNAL) != 0)
  ------------------
  |  |   77|     11|#define CFLAG_INTERNAL 0
  ------------------
  |  Branch (123:7): [True: 0, False: 11]
  ------------------
  124|      0|			continue;
  125|     11|		if (auth_only && c->auth_len == 0)
  ------------------
  |  Branch (125:7): [True: 0, False: 11]
  |  Branch (125:20): [True: 0, False: 0]
  ------------------
  126|      0|			continue;
  127|     11|		xextendf(&ret, sep_str, "%s", c->name);
  128|     11|	}
  129|      1|	return ret;
  130|      1|}
cipher_blocksize:
  145|      5|{
  146|      5|	return (c->block_size);
  147|      5|}
cipher_keylen:
  151|     11|{
  152|     11|	return (c->key_len);
  153|     11|}
cipher_seclen:
  157|      6|{
  158|      6|	if (strcmp("3des-cbc", c->name) == 0)
  ------------------
  |  Branch (158:6): [True: 0, False: 6]
  ------------------
  159|      0|		return 14;
  160|      6|	return cipher_keylen(c);
  161|      6|}
cipher_authlen:
  165|  2.14k|{
  166|  2.14k|	return (c->auth_len);
  167|  2.14k|}
cipher_ivlen:
  171|     10|{
  172|       |	/*
  173|       |	 * Default is cipher block size, except for chacha20+poly1305 that
  174|       |	 * needs no IV. XXX make iv_len == -1 default?
  175|       |	 */
  176|     10|	return (c->iv_len != 0 || (c->flags & CFLAG_CHACHAPOLY) != 0) ?
  ------------------
  |  |   74|     10|#define CFLAG_CHACHAPOLY	(1<<1)
  ------------------
  |  Branch (176:10): [True: 0, False: 10]
  |  Branch (176:28): [True: 0, False: 10]
  ------------------
  177|     10|	    c->iv_len : c->block_size;
  178|     10|}
cipher_ctx_is_plaintext:
  194|    810|{
  195|    810|	return cc->plaintext;
  196|    810|}
cipher_by_name:
  200|      7|{
  201|      7|	const struct sshcipher *c;
  202|     53|	for (c = ciphers; c->name != NULL; c++)
  ------------------
  |  Branch (202:20): [True: 53, False: 0]
  ------------------
  203|     53|		if (strcmp(c->name, name) == 0)
  ------------------
  |  Branch (203:7): [True: 7, False: 46]
  ------------------
  204|      7|			return c;
  205|      0|	return NULL;
  206|      7|}
cipher_warning_message:
  236|      4|{
  237|      4|	if (cc == NULL || cc->cipher == NULL)
  ------------------
  |  Branch (237:6): [True: 0, False: 4]
  |  Branch (237:20): [True: 0, False: 4]
  ------------------
  238|      0|		return NULL;
  239|       |	/* XXX repurpose for CBC warning */
  240|      4|	return NULL;
  241|      4|}
cipher_init:
  247|      9|{
  248|      9|	struct sshcipher_ctx *cc = NULL;
  249|      9|	int ret = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      9|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  250|      9|#ifdef WITH_OPENSSL
  251|      9|	const EVP_CIPHER *type;
  252|      9|	int klen;
  253|      9|#endif
  254|       |
  255|      9|	*ccp = NULL;
  256|      9|	if ((cc = calloc(1, sizeof(*cc))) == NULL)
  ------------------
  |  Branch (256:6): [True: 0, False: 9]
  ------------------
  257|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  258|       |
  259|      9|	cc->plaintext = (cipher->flags & CFLAG_NONE) != 0;
  ------------------
  |  |   76|      9|#define CFLAG_NONE		(1<<3)
  ------------------
  260|      9|	cc->encrypt = do_encrypt;
  261|       |
  262|      9|	if (keylen < cipher->key_len ||
  ------------------
  |  Branch (262:6): [True: 0, False: 9]
  ------------------
  263|      9|	    (iv != NULL && ivlen < cipher_ivlen(cipher))) {
  ------------------
  |  Branch (263:7): [True: 5, False: 4]
  |  Branch (263:21): [True: 0, False: 5]
  ------------------
  264|      0|		ret = SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  265|      0|		goto out;
  266|      0|	}
  267|       |
  268|      9|	cc->cipher = cipher;
  269|      9|	if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0) {
  ------------------
  |  |   74|      9|#define CFLAG_CHACHAPOLY	(1<<1)
  ------------------
  |  Branch (269:6): [True: 0, False: 9]
  ------------------
  270|      0|		cc->cp_ctx = chachapoly_new(key, keylen);
  271|      0|		ret = cc->cp_ctx != NULL ? 0 : SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  |  Branch (271:9): [True: 0, False: 0]
  ------------------
  272|      0|		goto out;
  273|      0|	}
  274|      9|	if ((cc->cipher->flags & CFLAG_NONE) != 0) {
  ------------------
  |  |   76|      9|#define CFLAG_NONE		(1<<3)
  ------------------
  |  Branch (274:6): [True: 5, False: 4]
  ------------------
  275|      5|		ret = 0;
  276|      5|		goto out;
  277|      5|	}
  278|       |#ifndef WITH_OPENSSL
  279|       |	if ((cc->cipher->flags & CFLAG_AESCTR) != 0) {
  280|       |		aesctr_keysetup(&cc->ac_ctx, key, 8 * keylen, 8 * ivlen);
  281|       |		aesctr_ivsetup(&cc->ac_ctx, iv);
  282|       |		ret = 0;
  283|       |		goto out;
  284|       |	}
  285|       |	ret = SSH_ERR_INVALID_ARGUMENT;
  286|       |	goto out;
  287|       |#else /* WITH_OPENSSL */
  288|      4|	type = (*cipher->evptype)();
  289|      4|	if ((cc->evp = EVP_CIPHER_CTX_new()) == NULL) {
  ------------------
  |  Branch (289:6): [True: 0, False: 4]
  ------------------
  290|      0|		ret = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  291|      0|		goto out;
  292|      0|	}
  293|      4|	if (EVP_CipherInit(cc->evp, type, NULL, (u_char *)iv,
  ------------------
  |  Branch (293:6): [True: 0, False: 4]
  ------------------
  294|      4|	    (do_encrypt == CIPHER_ENCRYPT)) == 0) {
  ------------------
  |  |   47|      4|#define CIPHER_ENCRYPT		1
  ------------------
  295|      0|		ret = SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  296|      0|		goto out;
  297|      0|	}
  298|      4|	if (cipher_authlen(cipher) &&
  ------------------
  |  Branch (298:6): [True: 0, False: 4]
  ------------------
  299|      0|	    EVP_CIPHER_CTX_ctrl(cc->evp, EVP_CTRL_GCM_SET_IV_FIXED,
  ------------------
  |  Branch (299:6): [True: 0, False: 0]
  ------------------
  300|      0|	    -1, (u_char *)iv) <= 0) {
  301|      0|		ret = SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  302|      0|		goto out;
  303|      0|	}
  304|      4|	klen = EVP_CIPHER_CTX_key_length(cc->evp);
  305|      4|	if (klen > 0 && keylen != (u_int)klen) {
  ------------------
  |  Branch (305:6): [True: 4, False: 0]
  |  Branch (305:18): [True: 0, False: 4]
  ------------------
  306|      0|		if (EVP_CIPHER_CTX_set_key_length(cc->evp, keylen) == 0) {
  ------------------
  |  Branch (306:7): [True: 0, False: 0]
  ------------------
  307|      0|			ret = SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  308|      0|			goto out;
  309|      0|		}
  310|      0|	}
  311|      4|	if (EVP_CipherInit(cc->evp, NULL, (u_char *)key, NULL, -1) == 0) {
  ------------------
  |  Branch (311:6): [True: 0, False: 4]
  ------------------
  312|      0|		ret = SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  313|      0|		goto out;
  314|      0|	}
  315|      4|	ret = 0;
  316|      4|#endif /* WITH_OPENSSL */
  317|      9| out:
  318|      9|	if (ret == 0) {
  ------------------
  |  Branch (318:6): [True: 9, False: 0]
  ------------------
  319|       |		/* success */
  320|      9|		*ccp = cc;
  321|      9|	} else {
  322|      0|		if (cc != NULL) {
  ------------------
  |  Branch (322:7): [True: 0, False: 0]
  ------------------
  323|      0|#ifdef WITH_OPENSSL
  324|      0|			EVP_CIPHER_CTX_free(cc->evp);
  325|      0|#endif /* WITH_OPENSSL */
  326|      0|			freezero(cc, sizeof(*cc));
  327|      0|		}
  328|      0|	}
  329|      9|	return ret;
  330|      4|}
cipher_crypt:
  345|  1.64k|{
  346|  1.64k|	if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0) {
  ------------------
  |  |   74|  1.64k|#define CFLAG_CHACHAPOLY	(1<<1)
  ------------------
  |  Branch (346:6): [True: 0, False: 1.64k]
  ------------------
  347|      0|		return chachapoly_crypt(cc->cp_ctx, seqnr, dest, src,
  348|      0|		    len, aadlen, authlen, cc->encrypt);
  349|      0|	}
  350|  1.64k|	if ((cc->cipher->flags & CFLAG_NONE) != 0) {
  ------------------
  |  |   76|  1.64k|#define CFLAG_NONE		(1<<3)
  ------------------
  |  Branch (350:6): [True: 19, False: 1.62k]
  ------------------
  351|     19|		memcpy(dest, src, aadlen + len);
  352|     19|		return 0;
  353|     19|	}
  354|       |#ifndef WITH_OPENSSL
  355|       |	if ((cc->cipher->flags & CFLAG_AESCTR) != 0) {
  356|       |		if (aadlen)
  357|       |			memcpy(dest, src, aadlen);
  358|       |		aesctr_encrypt_bytes(&cc->ac_ctx, src + aadlen,
  359|       |		    dest + aadlen, len);
  360|       |		return 0;
  361|       |	}
  362|       |	return SSH_ERR_INVALID_ARGUMENT;
  363|       |#else
  364|  1.62k|	if (authlen) {
  ------------------
  |  Branch (364:6): [True: 0, False: 1.62k]
  ------------------
  365|      0|		u_char lastiv[1];
  366|       |
  367|      0|		if (authlen != cipher_authlen(cc->cipher))
  ------------------
  |  Branch (367:7): [True: 0, False: 0]
  ------------------
  368|      0|			return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  369|       |		/* increment IV */
  370|      0|		if (EVP_CIPHER_CTX_ctrl(cc->evp, EVP_CTRL_GCM_IV_GEN,
  ------------------
  |  Branch (370:7): [True: 0, False: 0]
  ------------------
  371|      0|		    1, lastiv) <= 0)
  372|      0|			return SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  373|       |		/* set tag on decryption */
  374|      0|		if (!cc->encrypt &&
  ------------------
  |  Branch (374:7): [True: 0, False: 0]
  ------------------
  375|      0|		    EVP_CIPHER_CTX_ctrl(cc->evp, EVP_CTRL_GCM_SET_TAG,
  ------------------
  |  Branch (375:7): [True: 0, False: 0]
  ------------------
  376|      0|		    authlen, (u_char *)src + aadlen + len) <= 0)
  377|      0|			return SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  378|      0|	}
  379|  1.62k|	if (aadlen) {
  ------------------
  |  Branch (379:6): [True: 0, False: 1.62k]
  ------------------
  380|      0|		if (authlen &&
  ------------------
  |  Branch (380:7): [True: 0, False: 0]
  ------------------
  381|      0|		    EVP_Cipher(cc->evp, NULL, (u_char *)src, aadlen) < 0)
  ------------------
  |  Branch (381:7): [True: 0, False: 0]
  ------------------
  382|      0|			return SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  383|      0|		memcpy(dest, src, aadlen);
  384|      0|	}
  385|  1.62k|	if (len % cc->cipher->block_size)
  ------------------
  |  Branch (385:6): [True: 0, False: 1.62k]
  ------------------
  386|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  387|  1.62k|	if (EVP_Cipher(cc->evp, dest + aadlen, (u_char *)src + aadlen,
  ------------------
  |  Branch (387:6): [True: 0, False: 1.62k]
  ------------------
  388|  1.62k|	    len) < 0)
  389|      0|		return SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  390|  1.62k|	if (authlen) {
  ------------------
  |  Branch (390:6): [True: 0, False: 1.62k]
  ------------------
  391|       |		/* compute tag (on encrypt) or verify tag (on decrypt) */
  392|      0|		if (EVP_Cipher(cc->evp, NULL, NULL, 0) < 0)
  ------------------
  |  Branch (392:7): [True: 0, False: 0]
  ------------------
  393|      0|			return cc->encrypt ?
  ------------------
  |  Branch (393:11): [True: 0, False: 0]
  ------------------
  394|      0|			    SSH_ERR_LIBCRYPTO_ERROR : SSH_ERR_MAC_INVALID;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
              			    SSH_ERR_LIBCRYPTO_ERROR : SSH_ERR_MAC_INVALID;
  ------------------
  |  |   54|      0|#define SSH_ERR_MAC_INVALID			-30
  ------------------
  395|      0|		if (cc->encrypt &&
  ------------------
  |  Branch (395:7): [True: 0, False: 0]
  ------------------
  396|      0|		    EVP_CIPHER_CTX_ctrl(cc->evp, EVP_CTRL_GCM_GET_TAG,
  ------------------
  |  Branch (396:7): [True: 0, False: 0]
  ------------------
  397|      0|		    authlen, dest + aadlen + len) <= 0)
  398|      0|			return SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  399|      0|	}
  400|  1.62k|	return 0;
  401|  1.62k|#endif
  402|  1.62k|}
cipher_free:
  420|      5|{
  421|      5|	if (cc == NULL)
  ------------------
  |  Branch (421:6): [True: 0, False: 5]
  ------------------
  422|      0|		return;
  423|      5|	if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0) {
  ------------------
  |  |   74|      5|#define CFLAG_CHACHAPOLY	(1<<1)
  ------------------
  |  Branch (423:6): [True: 0, False: 5]
  ------------------
  424|      0|		chachapoly_free(cc->cp_ctx);
  425|      0|		cc->cp_ctx = NULL;
  426|      5|	} else if ((cc->cipher->flags & CFLAG_AESCTR) != 0)
  ------------------
  |  |   75|      5|#define CFLAG_AESCTR		(1<<2)
  ------------------
  |  Branch (426:13): [True: 0, False: 5]
  ------------------
  427|      0|		explicit_bzero(&cc->ac_ctx, sizeof(cc->ac_ctx));
  428|      5|#ifdef WITH_OPENSSL
  429|      5|	EVP_CIPHER_CTX_free(cc->evp);
  430|       |	cc->evp = NULL;
  431|      5|#endif
  432|      5|	freezero(cc, sizeof(*cc));
  433|      5|}

compat_banner:
   43|      2|{
   44|      2|	int i;
   45|      2|	static struct {
   46|      2|		char	*pat;
   47|      2|		uint32_t bugs;
   48|      2|	} check[] = {
   49|      2|		{ "OpenSSH_2.*,"
   50|      2|		  "OpenSSH_3.0*,"
   51|      2|		  "OpenSSH_3.1*",	SSH_BUG_EXTEOF|SSH_OLD_FORWARD_ADDR|
  ------------------
  |  |   50|      2|#define SSH_BUG_EXTEOF		0x00200000
  ------------------
              		  "OpenSSH_3.1*",	SSH_BUG_EXTEOF|SSH_OLD_FORWARD_ADDR|
  ------------------
  |  |   53|      2|#define SSH_OLD_FORWARD_ADDR	0x01000000
  ------------------
   52|      2|					SSH_BUG_SIGTYPE},
  ------------------
  |  |   31|      2|#define SSH_BUG_SIGTYPE		0x00000002
  ------------------
   53|      2|		{ "OpenSSH_3.*",	SSH_OLD_FORWARD_ADDR|SSH_BUG_SIGTYPE },
  ------------------
  |  |   53|      2|#define SSH_OLD_FORWARD_ADDR	0x01000000
  ------------------
              		{ "OpenSSH_3.*",	SSH_OLD_FORWARD_ADDR|SSH_BUG_SIGTYPE },
  ------------------
  |  |   31|      2|#define SSH_BUG_SIGTYPE		0x00000002
  ------------------
   54|      2|		{ "Sun_SSH_1.0*",	SSH_BUG_NOREKEY|SSH_BUG_EXTEOF|
  ------------------
  |  |   45|      2|#define SSH_BUG_NOREKEY		0x00008000
  ------------------
              		{ "Sun_SSH_1.0*",	SSH_BUG_NOREKEY|SSH_BUG_EXTEOF|
  ------------------
  |  |   50|      2|#define SSH_BUG_EXTEOF		0x00200000
  ------------------
   55|      2|					SSH_BUG_SIGTYPE},
  ------------------
  |  |   31|      2|#define SSH_BUG_SIGTYPE		0x00000002
  ------------------
   56|      2|		{ "OpenSSH_2*,"
   57|      2|		  "OpenSSH_3*,"
   58|      2|		  "OpenSSH_4*",		SSH_BUG_SIGTYPE },
  ------------------
  |  |   31|      2|#define SSH_BUG_SIGTYPE		0x00000002
  ------------------
   59|      2|		{ "OpenSSH_5*",		SSH_NEW_OPENSSH|SSH_BUG_DYNAMIC_RPORT|
  ------------------
  |  |   55|      2|#define SSH_NEW_OPENSSH		0x04000000
  ------------------
              		{ "OpenSSH_5*",		SSH_NEW_OPENSSH|SSH_BUG_DYNAMIC_RPORT|
  ------------------
  |  |   56|      2|#define SSH_BUG_DYNAMIC_RPORT	0x08000000
  ------------------
   60|      2|					SSH_BUG_SIGTYPE},
  ------------------
  |  |   31|      2|#define SSH_BUG_SIGTYPE		0x00000002
  ------------------
   61|      2|		{ "OpenSSH_6.6.1*",	SSH_NEW_OPENSSH|SSH_BUG_SIGTYPE},
  ------------------
  |  |   55|      2|#define SSH_NEW_OPENSSH		0x04000000
  ------------------
              		{ "OpenSSH_6.6.1*",	SSH_NEW_OPENSSH|SSH_BUG_SIGTYPE},
  ------------------
  |  |   31|      2|#define SSH_BUG_SIGTYPE		0x00000002
  ------------------
   62|      2|		{ "OpenSSH_6.5*,"
   63|      2|		  "OpenSSH_6.6*",	SSH_NEW_OPENSSH|SSH_BUG_CURVE25519PAD|
  ------------------
  |  |   55|      2|#define SSH_NEW_OPENSSH		0x04000000
  ------------------
              		  "OpenSSH_6.6*",	SSH_NEW_OPENSSH|SSH_BUG_CURVE25519PAD|
  ------------------
  |  |   57|      2|#define SSH_BUG_CURVE25519PAD	0x10000000
  ------------------
   64|      2|					SSH_BUG_SIGTYPE},
  ------------------
  |  |   31|      2|#define SSH_BUG_SIGTYPE		0x00000002
  ------------------
   65|      2|		{ "OpenSSH_7.4*",	SSH_NEW_OPENSSH|SSH_BUG_SIGTYPE|
  ------------------
  |  |   55|      2|#define SSH_NEW_OPENSSH		0x04000000
  ------------------
              		{ "OpenSSH_7.4*",	SSH_NEW_OPENSSH|SSH_BUG_SIGTYPE|
  ------------------
  |  |   31|      2|#define SSH_BUG_SIGTYPE		0x00000002
  ------------------
   66|      2|					SSH_BUG_SIGTYPE74},
  ------------------
  |  |   32|      2|#define SSH_BUG_SIGTYPE74	0x00000004
  ------------------
   67|      2|		{ "OpenSSH_7.0*,"
   68|      2|		  "OpenSSH_7.1*,"
   69|      2|		  "OpenSSH_7.2*,"
   70|      2|		  "OpenSSH_7.3*,"
   71|      2|		  "OpenSSH_7.5*,"
   72|      2|		  "OpenSSH_7.6*,"
   73|      2|		  "OpenSSH_7.7*",	SSH_NEW_OPENSSH|SSH_BUG_SIGTYPE},
  ------------------
  |  |   55|      2|#define SSH_NEW_OPENSSH		0x04000000
  ------------------
              		  "OpenSSH_7.7*",	SSH_NEW_OPENSSH|SSH_BUG_SIGTYPE},
  ------------------
  |  |   31|      2|#define SSH_BUG_SIGTYPE		0x00000002
  ------------------
   74|      2|		{ "OpenSSH*",		SSH_NEW_OPENSSH },
  ------------------
  |  |   55|      2|#define SSH_NEW_OPENSSH		0x04000000
  ------------------
   75|      2|		{ "*MindTerm*",		0 },
   76|      2|		{ "3.0.*",		SSH_BUG_DEBUG },
  ------------------
  |  |   36|      2|#define SSH_BUG_DEBUG		0x00000040
  ------------------
   77|      2|		{ "Cisco-1.*",		SSH_BUG_DHGEX_LARGE|
  ------------------
  |  |   59|      2|#define SSH_BUG_DHGEX_LARGE	0x40000000
  ------------------
   78|      2|					SSH_BUG_HOSTKEYS },
  ------------------
  |  |   58|      2|#define SSH_BUG_HOSTKEYS	0x20000000
  ------------------
   79|      2|		{ "*SSH_Version_Mapper*",
   80|      2|					SSH_BUG_SCANNER },
  ------------------
  |  |   41|      2|#define SSH_BUG_SCANNER		0x00000800
  ------------------
   81|      2|		{ "PuTTY_Local:*,"	/* dev versions < Sep 2014 */
   82|      2|		  "PuTTY-Release-0.5*," /* 0.50-0.57, DH-GEX in >=0.52 */
   83|      2|		  "PuTTY_Release_0.5*,"	/* 0.58-0.59 */
   84|      2|		  "PuTTY_Release_0.60*,"
   85|      2|		  "PuTTY_Release_0.61*,"
   86|      2|		  "PuTTY_Release_0.62*,"
   87|      2|		  "PuTTY_Release_0.63*,"
   88|      2|		  "PuTTY_Release_0.64*",
   89|      2|					SSH_OLD_DHGEX },
  ------------------
  |  |   44|      2|#define SSH_OLD_DHGEX		0x00004000
  ------------------
   90|      2|		{ "FuTTY*",		SSH_OLD_DHGEX }, /* Putty Fork */
  ------------------
  |  |   44|      2|#define SSH_OLD_DHGEX		0x00004000
  ------------------
   91|      2|		{ "Probe-*",
   92|      2|					SSH_BUG_PROBE },
  ------------------
  |  |   51|      2|#define SSH_BUG_PROBE		0x00400000
  ------------------
   93|      2|		{ "TeraTerm SSH*,"
   94|      2|		  "TTSSH/1.5.*,"
   95|      2|		  "TTSSH/2.1*,"
   96|      2|		  "TTSSH/2.2*,"
   97|      2|		  "TTSSH/2.3*,"
   98|      2|		  "TTSSH/2.4*,"
   99|      2|		  "TTSSH/2.5*,"
  100|      2|		  "TTSSH/2.6*,"
  101|      2|		  "TTSSH/2.70*,"
  102|      2|		  "TTSSH/2.71*,"
  103|      2|		  "TTSSH/2.72*",	SSH_BUG_HOSTKEYS },
  ------------------
  |  |   58|      2|#define SSH_BUG_HOSTKEYS	0x20000000
  ------------------
  104|      2|		{ "WinSCP_release_4*,"
  105|      2|		  "WinSCP_release_5.0*,"
  106|      2|		  "WinSCP_release_5.1,"
  107|      2|		  "WinSCP_release_5.1.*,"
  108|      2|		  "WinSCP_release_5.5,"
  109|      2|		  "WinSCP_release_5.5.*,"
  110|      2|		  "WinSCP_release_5.6,"
  111|      2|		  "WinSCP_release_5.6.*,"
  112|      2|		  "WinSCP_release_5.7,"
  113|      2|		  "WinSCP_release_5.7.1,"
  114|      2|		  "WinSCP_release_5.7.2,"
  115|      2|		  "WinSCP_release_5.7.3,"
  116|      2|		  "WinSCP_release_5.7.4",
  117|      2|					SSH_OLD_DHGEX },
  ------------------
  |  |   44|      2|#define SSH_OLD_DHGEX		0x00004000
  ------------------
  118|      2|		{ "ConfD-*",
  119|      2|					SSH_BUG_UTF8TTYMODE },
  ------------------
  |  |   30|      2|#define SSH_BUG_UTF8TTYMODE	0x00000001
  ------------------
  120|      2|		{ "Twisted_*",		0 },
  121|      2|		{ "Twisted*",		SSH_BUG_DEBUG },
  ------------------
  |  |   36|      2|#define SSH_BUG_DEBUG		0x00000040
  ------------------
  122|      2|		{ NULL,			0 }
  123|      2|	};
  124|       |
  125|       |	/* process table, return first match */
  126|      2|	ssh->compat = 0;
  127|     20|	for (i = 0; check[i].pat; i++) {
  ------------------
  |  Branch (127:14): [True: 20, False: 0]
  ------------------
  128|     20|		if (match_pattern_list(version, check[i].pat, 0) == 1) {
  ------------------
  |  Branch (128:7): [True: 2, False: 18]
  ------------------
  129|      2|			debug_f("match: %s pat %s compat 0x%08x",
  ------------------
  |  |  122|      2|#define debug_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  130|      2|			    version, check[i].pat, check[i].bugs);
  131|      2|			ssh->compat = check[i].bugs;
  132|      2|			return;
  133|      2|		}
  134|     20|	}
  135|      0|	debug_f("no match: %s", version);
  ------------------
  |  |  122|      0|#define debug_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  136|      0|}
compat_kex_proposal:
  141|      2|{
  142|      2|	char *cp = NULL, *cp2 = NULL;
  143|       |
  144|      2|	if ((ssh->compat & (SSH_BUG_CURVE25519PAD|SSH_OLD_DHGEX)) == 0)
  ------------------
  |  |   57|      2|#define SSH_BUG_CURVE25519PAD	0x10000000
  ------------------
              	if ((ssh->compat & (SSH_BUG_CURVE25519PAD|SSH_OLD_DHGEX)) == 0)
  ------------------
  |  |   44|      2|#define SSH_OLD_DHGEX		0x00004000
  ------------------
  |  Branch (144:6): [True: 2, False: 0]
  ------------------
  145|      2|		return xstrdup(p);
  146|      0|	debug2_f("original KEX proposal: %s", p);
  ------------------
  |  |  121|      0|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  147|      0|	if ((ssh->compat & SSH_BUG_CURVE25519PAD) != 0)
  ------------------
  |  |   57|      0|#define SSH_BUG_CURVE25519PAD	0x10000000
  ------------------
  |  Branch (147:6): [True: 0, False: 0]
  ------------------
  148|      0|		if ((cp = match_filter_denylist(p,
  ------------------
  |  Branch (148:7): [True: 0, False: 0]
  ------------------
  149|      0|		    "curve25519-sha256@libssh.org")) == NULL)
  150|      0|			fatal("match_filter_denylist failed");
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  151|      0|	if ((ssh->compat & SSH_OLD_DHGEX) != 0) {
  ------------------
  |  |   44|      0|#define SSH_OLD_DHGEX		0x00004000
  ------------------
  |  Branch (151:6): [True: 0, False: 0]
  ------------------
  152|      0|		if ((cp2 = match_filter_denylist(cp ? cp : p,
  ------------------
  |  Branch (152:7): [True: 0, False: 0]
  |  Branch (152:36): [True: 0, False: 0]
  ------------------
  153|      0|		    "diffie-hellman-group-exchange-sha256,"
  154|      0|		    "diffie-hellman-group-exchange-sha1")) == NULL)
  155|      0|			fatal("match_filter_denylist failed");
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  156|      0|		free(cp);
  157|      0|		cp = cp2;
  158|      0|	}
  159|      0|	if (cp == NULL || *cp == '\0')
  ------------------
  |  Branch (159:6): [True: 0, False: 0]
  |  Branch (159:20): [True: 0, False: 0]
  ------------------
  160|      0|		fatal("No supported key exchange algorithms found");
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  161|      0|	debug2_f("compat KEX proposal: %s", cp);
  ------------------
  |  |  121|      0|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  162|      0|	return cp;
  163|      0|}

ssh_digest_bytes:
  101|  1.53k|{
  102|  1.53k|	const struct ssh_digest *digest = ssh_digest_by_alg(alg);
  103|       |
  104|  1.53k|	return digest == NULL ? 0 : digest->digest_len;
  ------------------
  |  Branch (104:9): [True: 0, False: 1.53k]
  ------------------
  105|  1.53k|}
ssh_digest_blocksize:
  109|      4|{
  110|       |	return EVP_MD_CTX_block_size(ctx->mdctx);
  111|      4|}
ssh_digest_start:
  115|     24|{
  116|     24|	const struct ssh_digest *digest = ssh_digest_by_alg(alg);
  117|     24|	struct ssh_digest_ctx *ret;
  118|       |
  119|     24|	if (digest == NULL || ((ret = calloc(1, sizeof(*ret))) == NULL))
  ------------------
  |  Branch (119:6): [True: 0, False: 24]
  |  Branch (119:24): [True: 0, False: 24]
  ------------------
  120|      0|		return NULL;
  121|     24|	ret->alg = alg;
  122|     24|	if ((ret->mdctx = EVP_MD_CTX_new()) == NULL) {
  ------------------
  |  Branch (122:6): [True: 0, False: 24]
  ------------------
  123|      0|		free(ret);
  124|      0|		return NULL;
  125|      0|	}
  126|     24|	if (EVP_DigestInit_ex(ret->mdctx, digest->mdfunc(), NULL) != 1) {
  ------------------
  |  Branch (126:6): [True: 0, False: 24]
  ------------------
  127|      0|		ssh_digest_free(ret);
  128|      0|		return NULL;
  129|      0|	}
  130|     24|	return ret;
  131|     24|}
ssh_digest_copy_state:
  135|  2.44k|{
  136|  2.44k|	if (from->alg != to->alg)
  ------------------
  |  Branch (136:6): [True: 0, False: 2.44k]
  ------------------
  137|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  138|       |	/* we have bcopy-style order while openssl has memcpy-style */
  139|  2.44k|	if (!EVP_MD_CTX_copy_ex(to->mdctx, from->mdctx))
  ------------------
  |  Branch (139:6): [True: 0, False: 2.44k]
  ------------------
  140|      0|		return SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  141|  2.44k|	return 0;
  142|  2.44k|}
ssh_digest_update:
  146|  3.71k|{
  147|  3.71k|	if (EVP_DigestUpdate(ctx->mdctx, m, mlen) != 1)
  ------------------
  |  Branch (147:6): [True: 0, False: 3.71k]
  ------------------
  148|      0|		return SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  149|  3.71k|	return 0;
  150|  3.71k|}
ssh_digest_update_buffer:
  154|     24|{
  155|     24|	return ssh_digest_update(ctx, sshbuf_ptr(b), sshbuf_len(b));
  156|     24|}
ssh_digest_final:
  160|  2.44k|{
  161|  2.44k|	const struct ssh_digest *digest = ssh_digest_by_alg(ctx->alg);
  162|  2.44k|	u_int l = dlen;
  163|       |
  164|  2.44k|	if (digest == NULL || dlen > UINT_MAX)
  ------------------
  |  Branch (164:6): [True: 0, False: 2.44k]
  |  Branch (164:24): [True: 0, False: 2.44k]
  ------------------
  165|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  166|  2.44k|	if (dlen < digest->digest_len) /* No truncation allowed */
  ------------------
  |  Branch (166:6): [True: 0, False: 2.44k]
  ------------------
  167|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  168|  2.44k|	if (EVP_DigestFinal_ex(ctx->mdctx, d, &l) != 1)
  ------------------
  |  Branch (168:6): [True: 0, False: 2.44k]
  ------------------
  169|      0|		return SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  170|  2.44k|	if (l != digest->digest_len) /* sanity */
  ------------------
  |  Branch (170:6): [True: 0, False: 2.44k]
  ------------------
  171|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  172|  2.44k|	return 0;
  173|  2.44k|}
ssh_digest_free:
  177|     24|{
  178|     24|	if (ctx == NULL)
  ------------------
  |  Branch (178:6): [True: 12, False: 12]
  ------------------
  179|     12|		return;
  180|     12|	EVP_MD_CTX_free(ctx->mdctx);
  181|     12|	freezero(ctx, sizeof(*ctx));
  182|     12|}
ssh_digest_memory:
  186|    295|{
  187|    295|	const struct ssh_digest *digest = ssh_digest_by_alg(alg);
  188|    295|	u_int mdlen;
  189|       |
  190|    295|	if (digest == NULL)
  ------------------
  |  Branch (190:6): [True: 0, False: 295]
  ------------------
  191|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  192|    295|	if (dlen > UINT_MAX)
  ------------------
  |  Branch (192:6): [True: 0, False: 295]
  ------------------
  193|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  194|    295|	if (dlen < digest->digest_len)
  ------------------
  |  Branch (194:6): [True: 0, False: 295]
  ------------------
  195|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  196|    295|	mdlen = dlen;
  197|    295|	if (!EVP_Digest(m, mlen, d, &mdlen, digest->mdfunc(), NULL))
  ------------------
  |  Branch (197:6): [True: 0, False: 295]
  ------------------
  198|      0|		return SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  199|    295|	return 0;
  200|    295|}
ssh_digest_buffer:
  204|      2|{
  205|      2|	return ssh_digest_memory(alg, sshbuf_ptr(b), sshbuf_len(b), d, dlen);
  206|      2|}
digest-openssl.c:ssh_digest_by_alg:
   69|  4.29k|{
   70|  4.29k|	if (alg < 0 || alg >= SSH_DIGEST_MAX)
  ------------------
  |  |   30|  4.29k|#define SSH_DIGEST_MAX		5
  ------------------
  |  Branch (70:6): [True: 0, False: 4.29k]
  |  Branch (70:17): [True: 0, False: 4.29k]
  ------------------
   71|      0|		return NULL;
   72|  4.29k|	if (digests[alg].id != alg) /* sanity */
  ------------------
  |  Branch (72:6): [True: 0, False: 4.29k]
  ------------------
   73|      0|		return NULL;
   74|  4.29k|	if (digests[alg].mdfunc == NULL)
  ------------------
  |  Branch (74:6): [True: 0, False: 4.29k]
  ------------------
   75|      0|		return NULL;
   76|  4.29k|	return &(digests[alg]);
   77|  4.29k|}

ssh_dispatch_init:
   62|      1|{
   63|      1|	u_int i;
   64|    256|	for (i = 0; i < DISPATCH_MAX; i++)
  ------------------
  |  |   30|    256|#define DISPATCH_MAX	255
  ------------------
  |  Branch (64:14): [True: 255, False: 1]
  ------------------
   65|    255|		ssh->dispatch[i] = dflt;
   66|      1|}
ssh_dispatch_range:
   70|      4|{
   71|      4|	u_int i;
   72|       |
   73|    200|	for (i = from; i <= to; i++) {
  ------------------
  |  Branch (73:17): [True: 196, False: 4]
  ------------------
   74|    196|		if (i >= DISPATCH_MAX)
  ------------------
  |  |   30|    196|#define DISPATCH_MAX	255
  ------------------
  |  Branch (74:7): [True: 0, False: 196]
  ------------------
   75|      0|			break;
   76|    196|		ssh->dispatch[i] = fn;
   77|    196|	}
   78|      4|}
ssh_dispatch_set:
   82|    347|{
   83|    347|	ssh->dispatch[type] = fn;
   84|    347|}
ssh_dispatch_run:
   88|    513|{
   89|    513|	int r;
   90|    513|	u_char type;
   91|    513|	uint32_t seqnr;
   92|       |
   93|    808|	for (;;) {
   94|    808|		if (mode == DISPATCH_BLOCK) {
  ------------------
  |  Branch (94:7): [True: 0, False: 808]
  ------------------
   95|      0|			r = ssh_packet_read_seqnr(ssh, &type, &seqnr);
   96|      0|			if (r != 0)
  ------------------
  |  Branch (96:8): [True: 0, False: 0]
  ------------------
   97|      0|				return r;
   98|    808|		} else {
   99|    808|			r = ssh_packet_read_poll_seqnr(ssh, &type, &seqnr);
  100|    808|			if (r != 0)
  ------------------
  |  Branch (100:8): [True: 107, False: 701]
  ------------------
  101|    107|				return r;
  102|    701|			if (type == SSH_MSG_NONE)
  ------------------
  |  |   61|    701|#define SSH_MSG_NONE					0
  ------------------
  |  Branch (102:8): [True: 295, False: 406]
  ------------------
  103|    295|				return 0;
  104|    701|		}
  105|    406|		if (type > 0 && type < DISPATCH_MAX &&
  ------------------
  |  |   30|    812|#define DISPATCH_MAX	255
  ------------------
  |  Branch (105:7): [True: 406, False: 0]
  |  Branch (105:19): [True: 406, False: 0]
  ------------------
  106|    406|		    ssh->dispatch[type] != NULL) {
  ------------------
  |  Branch (106:7): [True: 406, False: 0]
  ------------------
  107|    406|			if (ssh->dispatch_skip_packets) {
  ------------------
  |  Branch (107:8): [True: 0, False: 406]
  ------------------
  108|      0|				debug2("skipped packet (type %u)", type);
  ------------------
  |  |  110|      0|#define debug2(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  109|      0|				ssh->dispatch_skip_packets--;
  110|      0|				continue;
  111|      0|			}
  112|    406|			r = (*ssh->dispatch[type])(type, seqnr, ssh);
  113|    406|			if (r != 0)
  ------------------
  |  Branch (113:8): [True: 75, False: 331]
  ------------------
  114|     75|				return r;
  115|    406|		} else {
  116|      0|			r = sshpkt_disconnect(ssh,
  117|      0|			    "protocol error: rcvd type %d", type);
  118|      0|			if (r != 0)
  ------------------
  |  Branch (118:8): [True: 0, False: 0]
  ------------------
  119|      0|				return r;
  120|      0|			return SSH_ERR_DISCONNECTED;
  ------------------
  |  |   53|      0|#define SSH_ERR_DISCONNECTED			-29
  ------------------
  121|      0|		}
  122|    331|		if (done != NULL && *done)
  ------------------
  |  Branch (122:7): [True: 0, False: 331]
  |  Branch (122:23): [True: 0, False: 0]
  ------------------
  123|      0|			return 0;
  124|    331|	}
  125|    513|}

crypto_sign_ed25519_detached:
  134|      1|{
  135|      1|	EVP_PKEY *pkey = NULL;
  136|      1|	EVP_MD_CTX *mdctx = NULL;
  137|      1|	size_t siglen;
  138|      1|	int ret = -1;
  139|       |
  140|       |	/* Create EVP_PKEY from secret key (first 32 bytes are the seed) */
  141|      1|	if ((pkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_ED25519, NULL,
  ------------------
  |  Branch (141:6): [True: 0, False: 1]
  ------------------
  142|      1|	    sk, SSH_ED25519_RAW_SECRET_KEY_LEN)) == NULL) {
  ------------------
  |  |   43|      1|    (crypto_sign_ed25519_SECRETKEYBYTES - crypto_sign_ed25519_PUBLICKEYBYTES)
  |  |  ------------------
  |  |  |  |   59|      1|#define crypto_sign_ed25519_SECRETKEYBYTES 64U
  |  |  ------------------
  |  |                   (crypto_sign_ed25519_SECRETKEYBYTES - crypto_sign_ed25519_PUBLICKEYBYTES)
  |  |  ------------------
  |  |  |  |   60|      1|#define crypto_sign_ed25519_PUBLICKEYBYTES 32U
  |  |  ------------------
  ------------------
  143|      0|		debug3_f("EVP_PKEY_new_raw_private_key failed");
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  144|      0|		goto out;
  145|      0|	}
  146|       |
  147|       |	/* Sign the message */
  148|      1|	if ((mdctx = EVP_MD_CTX_new()) == NULL) {
  ------------------
  |  Branch (148:6): [True: 0, False: 1]
  ------------------
  149|      0|		debug3_f("EVP_MD_CTX_new failed");
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  150|      0|		goto out;
  151|      0|	}
  152|      1|	if (EVP_DigestSignInit(mdctx, NULL, NULL, NULL, pkey) != 1) {
  ------------------
  |  Branch (152:6): [True: 0, False: 1]
  ------------------
  153|      0|		debug3_f("EVP_DigestSignInit failed");
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  154|      0|		goto out;
  155|      0|	}
  156|      1|	siglen = crypto_sign_ed25519_BYTES;
  ------------------
  |  |   62|      1|#define crypto_sign_ed25519_BYTES 64U
  ------------------
  157|      1|	if (EVP_DigestSign(mdctx, sig, &siglen, m, mlen) != 1) {
  ------------------
  |  Branch (157:6): [True: 0, False: 1]
  ------------------
  158|      0|		debug3_f("EVP_DigestSign failed");
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  159|      0|		goto out;
  160|      0|	}
  161|      1|	if (siglen != crypto_sign_ed25519_BYTES) {
  ------------------
  |  |   62|      1|#define crypto_sign_ed25519_BYTES 64U
  ------------------
  |  Branch (161:6): [True: 0, False: 1]
  ------------------
  162|      0|		debug3_f("signature length mismatch: %zu", siglen);
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  163|      0|		goto out;
  164|      0|	}
  165|       |
  166|      1|	if (siglenp != NULL)
  ------------------
  |  Branch (166:6): [True: 1, False: 0]
  ------------------
  167|      1|		*siglenp = siglen;
  168|       |
  169|      1|	ret = 0;
  170|      1|out:
  171|      1|	EVP_MD_CTX_free(mdctx);
  172|      1|	EVP_PKEY_free(pkey);
  173|      1|	return ret;
  174|      1|}
crypto_sign_ed25519_verify_detached:
  180|      1|{
  181|      1|	EVP_PKEY *pkey = NULL;
  182|      1|	EVP_MD_CTX *mdctx = NULL;
  183|      1|	int ret = -1;
  184|       |
  185|      1|	if (mlen > SIZE_MAX) {
  ------------------
  |  Branch (185:6): [True: 0, False: 1]
  ------------------
  186|      0|		debug3_f("message too long: %llu", mlen);
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  187|      0|		return -1;
  188|      0|	}
  189|       |
  190|       |	/* Create EVP_PKEY from public key */
  191|      1|	if ((pkey = EVP_PKEY_new_raw_public_key(EVP_PKEY_ED25519, NULL,
  ------------------
  |  Branch (191:6): [True: 0, False: 1]
  ------------------
  192|      1|	    pk, crypto_sign_ed25519_PUBLICKEYBYTES)) == NULL) {
  ------------------
  |  |   60|      1|#define crypto_sign_ed25519_PUBLICKEYBYTES 32U
  ------------------
  193|      0|		debug3_f("EVP_PKEY_new_raw_public_key failed");
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  194|      0|		goto out;
  195|      0|	}
  196|       |
  197|      1|	if ((mdctx = EVP_MD_CTX_new()) == NULL) {
  ------------------
  |  Branch (197:6): [True: 0, False: 1]
  ------------------
  198|      0|		debug3_f("EVP_MD_CTX_new failed");
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  199|      0|		goto out;
  200|      0|	}
  201|      1|	if (EVP_DigestVerifyInit(mdctx, NULL, NULL, NULL, pkey) <= 0) {
  ------------------
  |  Branch (201:6): [True: 0, False: 1]
  ------------------
  202|      0|		debug3_f("EVP_DigestVerifyInit failed");
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  203|      0|		goto out;
  204|      0|	}
  205|      1|	if (EVP_DigestVerify(mdctx, sig, crypto_sign_ed25519_BYTES,
  ------------------
  |  |   62|      1|#define crypto_sign_ed25519_BYTES 64U
  ------------------
  |  Branch (205:6): [True: 0, False: 1]
  ------------------
  206|      1|	    m, (size_t)mlen) != 1) {
  207|      0|		debug3_f("EVP_DigestVerify failed");
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  208|      0|		goto out;
  209|      0|	}
  210|       |
  211|      1|	ret = 0;
  212|      1|out:
  213|      1|	EVP_MD_CTX_free(mdctx);
  214|      1|	EVP_PKEY_free(pkey);
  215|      1|	return ret;
  216|      1|}

seed_rng:
   63|      1|{
   64|      1|	unsigned char buf[RANDOM_SEED_SIZE];
   65|       |
   66|       |	/* Initialise libcrypto */
   67|      1|	if (ssh_libcrypto_init() != 1)
  ------------------
  |  Branch (67:6): [True: 0, False: 1]
  ------------------
   68|      0|		fatal("libcrypto failed to initialize.");
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
   69|       |
   70|      1|	if (!ssh_compatible_openssl(OPENSSL_VERSION_NUMBER,
  ------------------
  |  Branch (70:6): [True: 0, False: 1]
  ------------------
   71|      1|	    OpenSSL_version_num()))
   72|      0|		fatal("OpenSSL version mismatch. Built against %lx, you "
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
   73|      1|		    "have %lx", (u_long)OPENSSL_VERSION_NUMBER,
   74|      1|		    OpenSSL_version_num());
   75|       |
   76|       |#ifndef OPENSSL_PRNG_ONLY
   77|       |	if (RAND_status() == 1)
   78|       |		debug3("RNG is ready, skipping seeding");
   79|       |	else {
   80|       |		if (seed_from_prngd(buf, sizeof(buf)) == -1)
   81|       |			fatal("Could not obtain seed from PRNGd");
   82|       |		RAND_add(buf, sizeof(buf), sizeof(buf));
   83|       |	}
   84|       |#endif /* OPENSSL_PRNG_ONLY */
   85|       |
   86|      1|	if (RAND_status() != 1)
  ------------------
  |  Branch (86:6): [True: 0, False: 1]
  ------------------
   87|      0|		fatal("PRNG is not seeded");
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
   88|       |
   89|       |	/* Ensure arc4random() is primed */
   90|      1|	arc4random_buf(buf, sizeof(buf));
   91|      1|	explicit_bzero(buf, sizeof(buf));
   92|      1|}

sshfatal:
   39|     36|{
   40|     36|	va_list args;
   41|       |
   42|     36|	va_start(args, fmt);
   43|     36|	sshlogv(file, func, line, showfunc, level, suffix, fmt, args);
   44|       |	va_end(args);
   45|     36|	cleanup_exit(255);
   46|     36|}

ssh_hmac_bytes:
   39|      4|{
   40|      4|	return ssh_digest_bytes(alg);
   41|      4|}
ssh_hmac_start:
   45|      4|{
   46|      4|	struct ssh_hmac_ctx	*ret;
   47|       |
   48|      4|	if ((ret = calloc(1, sizeof(*ret))) == NULL)
  ------------------
  |  Branch (48:6): [True: 0, False: 4]
  ------------------
   49|      0|		return NULL;
   50|      4|	ret->alg = alg;
   51|      4|	if ((ret->ictx = ssh_digest_start(alg)) == NULL ||
  ------------------
  |  Branch (51:6): [True: 0, False: 4]
  ------------------
   52|      4|	    (ret->octx = ssh_digest_start(alg)) == NULL ||
  ------------------
  |  Branch (52:6): [True: 0, False: 4]
  ------------------
   53|      4|	    (ret->digest = ssh_digest_start(alg)) == NULL)
  ------------------
  |  Branch (53:6): [True: 0, False: 4]
  ------------------
   54|      0|		goto fail;
   55|      4|	ret->buf_len = ssh_digest_blocksize(ret->ictx);
   56|      4|	if ((ret->buf = calloc(1, ret->buf_len)) == NULL)
  ------------------
  |  Branch (56:6): [True: 0, False: 4]
  ------------------
   57|      0|		goto fail;
   58|      4|	return ret;
   59|      0|fail:
   60|      0|	ssh_hmac_free(ret);
   61|       |	return NULL;
   62|      4|}
ssh_hmac_init:
   66|  1.22k|{
   67|  1.22k|	size_t i;
   68|       |
   69|       |	/* reset ictx and octx if no is key given */
   70|  1.22k|	if (key != NULL) {
  ------------------
  |  Branch (70:6): [True: 4, False: 1.21k]
  ------------------
   71|       |		/* truncate long keys */
   72|      4|		if (klen <= ctx->buf_len)
  ------------------
  |  Branch (72:7): [True: 4, False: 0]
  ------------------
   73|      4|			memcpy(ctx->buf, key, klen);
   74|      0|		else if (ssh_digest_memory(ctx->alg, key, klen, ctx->buf,
  ------------------
  |  Branch (74:12): [True: 0, False: 0]
  ------------------
   75|      0|		    ctx->buf_len) < 0)
   76|      0|			return -1;
   77|    260|		for (i = 0; i < ctx->buf_len; i++)
  ------------------
  |  Branch (77:15): [True: 256, False: 4]
  ------------------
   78|    256|			ctx->buf[i] ^= 0x36;
   79|      4|		if (ssh_digest_update(ctx->ictx, ctx->buf, ctx->buf_len) < 0)
  ------------------
  |  Branch (79:7): [True: 0, False: 4]
  ------------------
   80|      0|			return -1;
   81|    260|		for (i = 0; i < ctx->buf_len; i++)
  ------------------
  |  Branch (81:15): [True: 256, False: 4]
  ------------------
   82|    256|			ctx->buf[i] ^= 0x36 ^ 0x5c;
   83|      4|		if (ssh_digest_update(ctx->octx, ctx->buf, ctx->buf_len) < 0)
  ------------------
  |  Branch (83:7): [True: 0, False: 4]
  ------------------
   84|      0|			return -1;
   85|      4|		explicit_bzero(ctx->buf, ctx->buf_len);
   86|      4|	}
   87|       |	/* start with ictx */
   88|  1.22k|	if (ssh_digest_copy_state(ctx->ictx, ctx->digest) < 0)
  ------------------
  |  Branch (88:6): [True: 0, False: 1.22k]
  ------------------
   89|      0|		return -1;
   90|  1.22k|	return 0;
   91|  1.22k|}
ssh_hmac_update:
   95|  2.43k|{
   96|  2.43k|	return ssh_digest_update(ctx->digest, m, mlen);
   97|  2.43k|}
ssh_hmac_final:
  107|  1.21k|{
  108|  1.21k|	size_t len;
  109|       |
  110|  1.21k|	len = ssh_digest_bytes(ctx->alg);
  111|  1.21k|	if (dlen < len ||
  ------------------
  |  Branch (111:6): [True: 0, False: 1.21k]
  ------------------
  112|  1.21k|	    ssh_digest_final(ctx->digest, ctx->buf, len))
  ------------------
  |  Branch (112:6): [True: 0, False: 1.21k]
  ------------------
  113|      0|		return -1;
  114|       |	/* switch to octx */
  115|  1.21k|	if (ssh_digest_copy_state(ctx->octx, ctx->digest) < 0 ||
  ------------------
  |  Branch (115:6): [True: 0, False: 1.21k]
  ------------------
  116|  1.21k|	    ssh_digest_update(ctx->digest, ctx->buf, len) < 0 ||
  ------------------
  |  Branch (116:6): [True: 0, False: 1.21k]
  ------------------
  117|  1.21k|	    ssh_digest_final(ctx->digest, d, dlen) < 0)
  ------------------
  |  Branch (117:6): [True: 0, False: 1.21k]
  ------------------
  118|      0|		return -1;
  119|  1.21k|	return 0;
  120|  1.21k|}

kex_alg_list:
   92|      1|{
   93|      1|	char *ret = NULL;
   94|      1|	const struct kexalg *k;
   95|      1|	char sep_str[2] = {sep, '\0'};
   96|       |
   97|     17|	for (k = kexalgs; k->name != NULL; k++)
  ------------------
  |  Branch (97:20): [True: 16, False: 1]
  ------------------
   98|     16|		xextendf(&ret, sep_str, "%s", k->name);
   99|       |
  100|      1|	return ret;
  101|      1|}
kex_name_valid:
  117|      2|{
  118|       |	return kex_alg_by_name(name) != NULL;
  119|      2|}
kex_type_from_name:
  133|      2|{
  134|      2|	const struct kexalg *k;
  135|       |
  136|      2|	if ((k = kex_alg_by_name(name)) == NULL)
  ------------------
  |  Branch (136:6): [True: 0, False: 2]
  ------------------
  137|      0|		return 0;
  138|      2|	return k->type;
  139|      2|}
kex_hash_from_name:
  143|      2|{
  144|      2|	const struct kexalg *k;
  145|       |
  146|      2|	if ((k = kex_alg_by_name(name)) == NULL)
  ------------------
  |  Branch (146:6): [True: 0, False: 2]
  ------------------
  147|      0|		return -1;
  148|      2|	return k->hash_alg;
  149|      2|}
kex_nid_from_name:
  153|      2|{
  154|      2|	const struct kexalg *k;
  155|       |
  156|      2|	if ((k = kex_alg_by_name(name)) == NULL)
  ------------------
  |  Branch (156:6): [True: 0, False: 2]
  ------------------
  157|      0|		return -1;
  158|      2|	return k->ec_nid;
  159|      2|}
kex_has_any_alg:
  187|     10|{
  188|     10|	char *cp;
  189|       |
  190|     10|	if ((cp = match_list(proposal, algs, NULL)) == NULL)
  ------------------
  |  Branch (190:6): [True: 6, False: 4]
  ------------------
  191|      6|		return 0;
  192|      4|	free(cp);
  193|      4|	return 1;
  194|     10|}
kex_names_cat:
  202|      2|{
  203|      2|	char *ret = NULL, *tmp = NULL, *cp, *p;
  204|      2|	size_t len;
  205|       |
  206|      2|	if (a == NULL || *a == '\0')
  ------------------
  |  Branch (206:6): [True: 0, False: 2]
  |  Branch (206:19): [True: 0, False: 2]
  ------------------
  207|      0|		return strdup(b);
  208|      2|	if (b == NULL || *b == '\0')
  ------------------
  |  Branch (208:6): [True: 0, False: 2]
  |  Branch (208:19): [True: 0, False: 2]
  ------------------
  209|      0|		return strdup(a);
  210|      2|	if (strlen(b) > 1024*1024)
  ------------------
  |  Branch (210:6): [True: 0, False: 2]
  ------------------
  211|      0|		return NULL;
  212|      2|	len = strlen(a) + strlen(b) + 2;
  213|      2|	if ((tmp = cp = strdup(b)) == NULL ||
  ------------------
  |  Branch (213:6): [True: 0, False: 2]
  ------------------
  214|      2|	    (ret = calloc(1, len)) == NULL) {
  ------------------
  |  Branch (214:6): [True: 0, False: 2]
  ------------------
  215|      0|		free(tmp);
  216|      0|		return NULL;
  217|      0|	}
  218|      2|	strlcpy(ret, a, len);
  219|      6|	for ((p = strsep(&cp, ",")); p && *p != '\0'; (p = strsep(&cp, ","))) {
  ------------------
  |  Branch (219:31): [True: 4, False: 2]
  |  Branch (219:36): [True: 4, False: 0]
  ------------------
  220|      4|		if (kex_has_any_alg(ret, p))
  ------------------
  |  Branch (220:7): [True: 0, False: 4]
  ------------------
  221|      0|			continue; /* Algorithm already present */
  222|      4|		if (strlcat(ret, ",", len) >= len ||
  ------------------
  |  Branch (222:7): [True: 0, False: 4]
  ------------------
  223|      4|		    strlcat(ret, p, len) >= len) {
  ------------------
  |  Branch (223:7): [True: 0, False: 4]
  ------------------
  224|      0|			free(tmp);
  225|      0|			free(ret);
  226|      0|			return NULL; /* Shouldn't happen */
  227|      0|		}
  228|      4|	}
  229|      2|	free(tmp);
  230|      2|	return ret;
  231|      2|}
kex_assemble_names:
  242|      7|{
  243|      7|	char *cp, *tmp, *patterns;
  244|      7|	char *list = NULL, *ret = NULL, *matching = NULL, *opatterns = NULL;
  245|      7|	int r = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      7|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  246|       |
  247|      7|	if (listp == NULL || def == NULL || all == NULL)
  ------------------
  |  Branch (247:6): [True: 0, False: 7]
  |  Branch (247:23): [True: 0, False: 7]
  |  Branch (247:38): [True: 0, False: 7]
  ------------------
  248|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  249|       |
  250|      7|	if (*listp == NULL || **listp == '\0') {
  ------------------
  |  Branch (250:6): [True: 7, False: 0]
  |  Branch (250:24): [True: 0, False: 0]
  ------------------
  251|      7|		if ((*listp = strdup(def)) == NULL)
  ------------------
  |  Branch (251:7): [True: 0, False: 7]
  ------------------
  252|      0|			return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  253|      7|		return 0;
  254|      7|	}
  255|       |
  256|      0|	list = *listp;
  257|      0|	*listp = NULL;
  258|      0|	if (*list == '+') {
  ------------------
  |  Branch (258:6): [True: 0, False: 0]
  ------------------
  259|       |		/* Append names to default list */
  260|      0|		if ((tmp = kex_names_cat(def, list + 1)) == NULL) {
  ------------------
  |  Branch (260:7): [True: 0, False: 0]
  ------------------
  261|      0|			r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  262|      0|			goto fail;
  263|      0|		}
  264|      0|		free(list);
  265|      0|		list = tmp;
  266|      0|	} else if (*list == '-') {
  ------------------
  |  Branch (266:13): [True: 0, False: 0]
  ------------------
  267|       |		/* Remove names from default list */
  268|      0|		if ((*listp = match_filter_denylist(def, list + 1)) == NULL) {
  ------------------
  |  Branch (268:7): [True: 0, False: 0]
  ------------------
  269|      0|			r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  270|      0|			goto fail;
  271|      0|		}
  272|      0|		free(list);
  273|       |		/* filtering has already been done */
  274|      0|		return 0;
  275|      0|	} else if (*list == '^') {
  ------------------
  |  Branch (275:13): [True: 0, False: 0]
  ------------------
  276|       |		/* Place names at head of default list */
  277|      0|		if ((tmp = kex_names_cat(list + 1, def)) == NULL) {
  ------------------
  |  Branch (277:7): [True: 0, False: 0]
  ------------------
  278|      0|			r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  279|      0|			goto fail;
  280|      0|		}
  281|      0|		free(list);
  282|      0|		list = tmp;
  283|      0|	} else {
  284|       |		/* Explicit list, overrides default - just use "list" as is */
  285|      0|	}
  286|       |
  287|       |	/*
  288|       |	 * The supplied names may be a pattern-list. For the -list case,
  289|       |	 * the patterns are applied above. For the +list and explicit list
  290|       |	 * cases we need to do it now.
  291|       |	 */
  292|      0|	ret = NULL;
  293|      0|	if ((patterns = opatterns = strdup(list)) == NULL) {
  ------------------
  |  Branch (293:6): [True: 0, False: 0]
  ------------------
  294|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  295|      0|		goto fail;
  296|      0|	}
  297|       |	/* Apply positive (i.e. non-negated) patterns from the list */
  298|      0|	while ((cp = strsep(&patterns, ",")) != NULL) {
  ------------------
  |  Branch (298:9): [True: 0, False: 0]
  ------------------
  299|      0|		if (*cp == '!') {
  ------------------
  |  Branch (299:7): [True: 0, False: 0]
  ------------------
  300|       |			/* negated matches are not supported here */
  301|      0|			r = SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  302|      0|			goto fail;
  303|      0|		}
  304|      0|		free(matching);
  305|      0|		if ((matching = match_filter_allowlist(all, cp)) == NULL) {
  ------------------
  |  Branch (305:7): [True: 0, False: 0]
  ------------------
  306|      0|			r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  307|      0|			goto fail;
  308|      0|		}
  309|      0|		if ((tmp = kex_names_cat(ret, matching)) == NULL) {
  ------------------
  |  Branch (309:7): [True: 0, False: 0]
  ------------------
  310|      0|			r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  311|      0|			goto fail;
  312|      0|		}
  313|      0|		free(ret);
  314|      0|		ret = tmp;
  315|      0|	}
  316|      0|	if (ret == NULL || *ret == '\0') {
  ------------------
  |  Branch (316:6): [True: 0, False: 0]
  |  Branch (316:21): [True: 0, False: 0]
  ------------------
  317|       |		/* An empty name-list is an error */
  318|       |		/* XXX better error code? */
  319|      0|		r = SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  320|      0|		goto fail;
  321|      0|	}
  322|       |
  323|       |	/* success */
  324|      0|	*listp = ret;
  325|      0|	ret = NULL;
  326|      0|	r = 0;
  327|       |
  328|      0| fail:
  329|      0|	free(matching);
  330|      0|	free(opatterns);
  331|      0|	free(list);
  332|      0|	free(ret);
  333|      0|	return r;
  334|      0|}
kex-names.c:kex_alg_by_name:
  105|      8|{
  106|      8|	const struct kexalg *k;
  107|       |
  108|     96|	for (k = kexalgs; k->name != NULL; k++) {
  ------------------
  |  Branch (108:20): [True: 96, False: 0]
  ------------------
  109|     96|		if (strcmp(k->name, name) == 0)
  ------------------
  |  Branch (109:7): [True: 8, False: 88]
  ------------------
  110|      8|			return k;
  111|     96|	}
  112|      0|	return NULL;
  113|      8|}

kex_proposal_populate_entries:
   90|      2|{
   91|      2|	const char *defpropserver[PROPOSAL_MAX] = { KEX_SERVER };
  ------------------
  |  |  115|      2|	KEX_SERVER_KEX, \
  |  |  ------------------
  |  |  |  |   28|      2|	"mlkem768x25519-sha256," \
  |  |  |  |   29|      2|	"sntrup761x25519-sha512," \
  |  |  |  |   30|      2|	"sntrup761x25519-sha512@openssh.com," \
  |  |  |  |   31|      2|	"curve25519-sha256," \
  |  |  |  |   32|      2|	"curve25519-sha256@libssh.org," \
  |  |  |  |   33|      2|	"ecdh-sha2-nistp256," \
  |  |  |  |   34|      2|	"ecdh-sha2-nistp384," \
  |  |  |  |   35|      2|	"ecdh-sha2-nistp521" \
  |  |  ------------------
  |  |  116|      2|	KEX_DEFAULT_PK_ALG, \
  |  |  ------------------
  |  |  |  |   44|      2|	"ssh-ed25519-cert-v01@openssh.com," \
  |  |  |  |   45|      2|	"ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |  |  |   46|      2|	"ecdsa-sha2-nistp384-cert-v01@openssh.com," \
  |  |  |  |   47|      2|	"ecdsa-sha2-nistp521-cert-v01@openssh.com," \
  |  |  |  |   48|      2|	"sk-ssh-ed25519-cert-v01@openssh.com," \
  |  |  |  |   49|      2|	"sk-ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |  |  |   50|      2|	"webauthn-sk-ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |  |  |   51|      2|	"rsa-sha2-512-cert-v01@openssh.com," \
  |  |  |  |   52|      2|	"rsa-sha2-256-cert-v01@openssh.com," \
  |  |  |  |   53|      2|	"ssh-mldsa44-ed25519-cert," \
  |  |  |  |   54|      2|	"ssh-ed25519," \
  |  |  |  |   55|      2|	"ecdsa-sha2-nistp256," \
  |  |  |  |   56|      2|	"ecdsa-sha2-nistp384," \
  |  |  |  |   57|      2|	"ecdsa-sha2-nistp521," \
  |  |  |  |   58|      2|	"sk-ssh-ed25519@openssh.com," \
  |  |  |  |   59|      2|	"sk-ecdsa-sha2-nistp256@openssh.com," \
  |  |  |  |   60|      2|	"webauthn-sk-ecdsa-sha2-nistp256@openssh.com," \
  |  |  |  |   61|      2|	"rsa-sha2-512," \
  |  |  |  |   62|      2|	"rsa-sha2-256," \
  |  |  |  |   63|      2|	"ssh-mldsa44-ed25519"
  |  |  ------------------
  |  |  117|      2|	KEX_SERVER_ENCRYPT, \
  |  |  ------------------
  |  |  |  |   66|      2|	"chacha20-poly1305@openssh.com," \
  |  |  |  |   67|      2|	"aes128-gcm@openssh.com,aes256-gcm@openssh.com," \
  |  |  |  |   68|      2|	"aes128-ctr,aes192-ctr,aes256-ctr"
  |  |  ------------------
  |  |  118|      2|	KEX_SERVER_ENCRYPT, \
  |  |  ------------------
  |  |  |  |   66|      2|	"chacha20-poly1305@openssh.com," \
  |  |  |  |   67|      2|	"aes128-gcm@openssh.com,aes256-gcm@openssh.com," \
  |  |  |  |   68|      2|	"aes128-ctr,aes192-ctr,aes256-ctr"
  |  |  ------------------
  |  |  119|      2|	KEX_SERVER_MAC, \
  |  |  ------------------
  |  |  |  |   73|      2|	"umac-64-etm@openssh.com," \
  |  |  |  |   74|      2|	"umac-128-etm@openssh.com," \
  |  |  |  |   75|      2|	"hmac-sha2-256-etm@openssh.com," \
  |  |  |  |   76|      2|	"hmac-sha2-512-etm@openssh.com," \
  |  |  |  |   77|      2|	"hmac-sha1-etm@openssh.com," \
  |  |  |  |   78|      2|	"umac-64@openssh.com," \
  |  |  |  |   79|      2|	"umac-128@openssh.com," \
  |  |  |  |   80|      2|	"hmac-sha2-256," \
  |  |  |  |   81|      2|	"hmac-sha2-512," \
  |  |  |  |   82|      2|	"hmac-sha1"
  |  |  ------------------
  |  |  120|      2|	KEX_SERVER_MAC, \
  |  |  ------------------
  |  |  |  |   73|      2|	"umac-64-etm@openssh.com," \
  |  |  |  |   74|      2|	"umac-128-etm@openssh.com," \
  |  |  |  |   75|      2|	"hmac-sha2-256-etm@openssh.com," \
  |  |  |  |   76|      2|	"hmac-sha2-512-etm@openssh.com," \
  |  |  |  |   77|      2|	"hmac-sha1-etm@openssh.com," \
  |  |  |  |   78|      2|	"umac-64@openssh.com," \
  |  |  |  |   79|      2|	"umac-128@openssh.com," \
  |  |  |  |   80|      2|	"hmac-sha2-256," \
  |  |  |  |   81|      2|	"hmac-sha2-512," \
  |  |  |  |   82|      2|	"hmac-sha1"
  |  |  ------------------
  |  |  121|      2|	KEX_DEFAULT_COMP, \
  |  |  ------------------
  |  |  |  |   99|      2|#define	KEX_DEFAULT_COMP	"none,zlib@openssh.com"
  |  |  ------------------
  |  |  122|      2|	KEX_DEFAULT_COMP, \
  |  |  ------------------
  |  |  |  |   99|      2|#define	KEX_DEFAULT_COMP	"none,zlib@openssh.com"
  |  |  ------------------
  |  |  123|      2|	KEX_DEFAULT_LANG, \
  |  |  ------------------
  |  |  |  |  100|      2|#define	KEX_DEFAULT_LANG	""
  |  |  ------------------
  |  |  124|      2|	KEX_DEFAULT_LANG
  |  |  ------------------
  |  |  |  |  100|      2|#define	KEX_DEFAULT_LANG	""
  |  |  ------------------
  ------------------
   92|      2|	const char *defpropclient[PROPOSAL_MAX] = { KEX_CLIENT };
  ------------------
  |  |  103|      2|	KEX_CLIENT_KEX, \
  |  |  ------------------
  |  |  |  |   37|      2|#define KEX_CLIENT_KEX KEX_SERVER_KEX "," \
  |  |  |  |  ------------------
  |  |  |  |  |  |   28|      2|	"mlkem768x25519-sha256," \
  |  |  |  |  |  |   29|      2|	"sntrup761x25519-sha512," \
  |  |  |  |  |  |   30|      2|	"sntrup761x25519-sha512@openssh.com," \
  |  |  |  |  |  |   31|      2|	"curve25519-sha256," \
  |  |  |  |  |  |   32|      2|	"curve25519-sha256@libssh.org," \
  |  |  |  |  |  |   33|      2|	"ecdh-sha2-nistp256," \
  |  |  |  |  |  |   34|      2|	"ecdh-sha2-nistp384," \
  |  |  |  |  |  |   35|      2|	"ecdh-sha2-nistp521" \
  |  |  |  |  ------------------
  |  |  |  |   38|      2|	"diffie-hellman-group-exchange-sha256," \
  |  |  |  |   39|      2|	"diffie-hellman-group16-sha512," \
  |  |  |  |   40|      2|	"diffie-hellman-group18-sha512," \
  |  |  |  |   41|      2|	"diffie-hellman-group14-sha256"
  |  |  ------------------
  |  |  104|      2|	KEX_DEFAULT_PK_ALG, \
  |  |  ------------------
  |  |  |  |   44|      2|	"ssh-ed25519-cert-v01@openssh.com," \
  |  |  |  |   45|      2|	"ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |  |  |   46|      2|	"ecdsa-sha2-nistp384-cert-v01@openssh.com," \
  |  |  |  |   47|      2|	"ecdsa-sha2-nistp521-cert-v01@openssh.com," \
  |  |  |  |   48|      2|	"sk-ssh-ed25519-cert-v01@openssh.com," \
  |  |  |  |   49|      2|	"sk-ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |  |  |   50|      2|	"webauthn-sk-ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |  |  |   51|      2|	"rsa-sha2-512-cert-v01@openssh.com," \
  |  |  |  |   52|      2|	"rsa-sha2-256-cert-v01@openssh.com," \
  |  |  |  |   53|      2|	"ssh-mldsa44-ed25519-cert," \
  |  |  |  |   54|      2|	"ssh-ed25519," \
  |  |  |  |   55|      2|	"ecdsa-sha2-nistp256," \
  |  |  |  |   56|      2|	"ecdsa-sha2-nistp384," \
  |  |  |  |   57|      2|	"ecdsa-sha2-nistp521," \
  |  |  |  |   58|      2|	"sk-ssh-ed25519@openssh.com," \
  |  |  |  |   59|      2|	"sk-ecdsa-sha2-nistp256@openssh.com," \
  |  |  |  |   60|      2|	"webauthn-sk-ecdsa-sha2-nistp256@openssh.com," \
  |  |  |  |   61|      2|	"rsa-sha2-512," \
  |  |  |  |   62|      2|	"rsa-sha2-256," \
  |  |  |  |   63|      2|	"ssh-mldsa44-ed25519"
  |  |  ------------------
  |  |  105|      2|	KEX_CLIENT_ENCRYPT, \
  |  |  ------------------
  |  |  |  |   70|      2|#define KEX_CLIENT_ENCRYPT KEX_SERVER_ENCRYPT
  |  |  |  |  ------------------
  |  |  |  |  |  |   66|      2|	"chacha20-poly1305@openssh.com," \
  |  |  |  |  |  |   67|      2|	"aes128-gcm@openssh.com,aes256-gcm@openssh.com," \
  |  |  |  |  |  |   68|      2|	"aes128-ctr,aes192-ctr,aes256-ctr"
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  106|      2|	KEX_CLIENT_ENCRYPT, \
  |  |  ------------------
  |  |  |  |   70|      2|#define KEX_CLIENT_ENCRYPT KEX_SERVER_ENCRYPT
  |  |  |  |  ------------------
  |  |  |  |  |  |   66|      2|	"chacha20-poly1305@openssh.com," \
  |  |  |  |  |  |   67|      2|	"aes128-gcm@openssh.com,aes256-gcm@openssh.com," \
  |  |  |  |  |  |   68|      2|	"aes128-ctr,aes192-ctr,aes256-ctr"
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      2|	KEX_CLIENT_MAC, \
  |  |  ------------------
  |  |  |  |   84|      2|#define KEX_CLIENT_MAC KEX_SERVER_MAC
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|      2|	"umac-64-etm@openssh.com," \
  |  |  |  |  |  |   74|      2|	"umac-128-etm@openssh.com," \
  |  |  |  |  |  |   75|      2|	"hmac-sha2-256-etm@openssh.com," \
  |  |  |  |  |  |   76|      2|	"hmac-sha2-512-etm@openssh.com," \
  |  |  |  |  |  |   77|      2|	"hmac-sha1-etm@openssh.com," \
  |  |  |  |  |  |   78|      2|	"umac-64@openssh.com," \
  |  |  |  |  |  |   79|      2|	"umac-128@openssh.com," \
  |  |  |  |  |  |   80|      2|	"hmac-sha2-256," \
  |  |  |  |  |  |   81|      2|	"hmac-sha2-512," \
  |  |  |  |  |  |   82|      2|	"hmac-sha1"
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|      2|	KEX_CLIENT_MAC, \
  |  |  ------------------
  |  |  |  |   84|      2|#define KEX_CLIENT_MAC KEX_SERVER_MAC
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|      2|	"umac-64-etm@openssh.com," \
  |  |  |  |  |  |   74|      2|	"umac-128-etm@openssh.com," \
  |  |  |  |  |  |   75|      2|	"hmac-sha2-256-etm@openssh.com," \
  |  |  |  |  |  |   76|      2|	"hmac-sha2-512-etm@openssh.com," \
  |  |  |  |  |  |   77|      2|	"hmac-sha1-etm@openssh.com," \
  |  |  |  |  |  |   78|      2|	"umac-64@openssh.com," \
  |  |  |  |  |  |   79|      2|	"umac-128@openssh.com," \
  |  |  |  |  |  |   80|      2|	"hmac-sha2-256," \
  |  |  |  |  |  |   81|      2|	"hmac-sha2-512," \
  |  |  |  |  |  |   82|      2|	"hmac-sha1"
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  109|      2|	KEX_DEFAULT_COMP, \
  |  |  ------------------
  |  |  |  |   99|      2|#define	KEX_DEFAULT_COMP	"none,zlib@openssh.com"
  |  |  ------------------
  |  |  110|      2|	KEX_DEFAULT_COMP, \
  |  |  ------------------
  |  |  |  |   99|      2|#define	KEX_DEFAULT_COMP	"none,zlib@openssh.com"
  |  |  ------------------
  |  |  111|      2|	KEX_DEFAULT_LANG, \
  |  |  ------------------
  |  |  |  |  100|      2|#define	KEX_DEFAULT_LANG	""
  |  |  ------------------
  |  |  112|      2|	KEX_DEFAULT_LANG
  |  |  ------------------
  |  |  |  |  100|      2|#define	KEX_DEFAULT_LANG	""
  |  |  ------------------
  ------------------
   93|      2|	const char **defprop = ssh->kex->server ? defpropserver : defpropclient;
  ------------------
  |  Branch (93:25): [True: 1, False: 1]
  ------------------
   94|      2|	u_int i;
   95|      2|	char *cp;
   96|       |
   97|      2|	if (prop == NULL)
  ------------------
  |  Branch (97:6): [True: 0, False: 2]
  ------------------
   98|      0|		fatal_f("proposal missing");
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
   99|       |
  100|       |	/* Append EXT_INFO signalling to KexAlgorithms */
  101|      2|	if (kexalgos == NULL)
  ------------------
  |  Branch (101:6): [True: 0, False: 2]
  ------------------
  102|      0|		kexalgos = defprop[PROPOSAL_KEX_ALGS];
  103|      2|	if ((cp = kex_names_cat(kexalgos, ssh->kex->server ?
  ------------------
  |  Branch (103:6): [True: 0, False: 2]
  |  Branch (103:36): [True: 1, False: 1]
  ------------------
  104|      1|	    "ext-info-s,kex-strict-s-v00@openssh.com" :
  105|      2|	    "ext-info-c,kex-strict-c-v00@openssh.com")) == NULL)
  106|      0|		fatal_f("kex_names_cat");
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  107|       |
  108|     22|	for (i = 0; i < PROPOSAL_MAX; i++) {
  ------------------
  |  Branch (108:14): [True: 20, False: 2]
  ------------------
  109|     20|		switch(i) {
  110|      2|		case PROPOSAL_KEX_ALGS:
  ------------------
  |  Branch (110:3): [True: 2, False: 18]
  ------------------
  111|      2|			prop[i] = compat_kex_proposal(ssh, cp);
  112|      2|			break;
  113|      2|		case PROPOSAL_ENC_ALGS_CTOS:
  ------------------
  |  Branch (113:3): [True: 2, False: 18]
  ------------------
  114|      4|		case PROPOSAL_ENC_ALGS_STOC:
  ------------------
  |  Branch (114:3): [True: 2, False: 18]
  ------------------
  115|      4|			prop[i] = xstrdup(ciphers ? ciphers : defprop[i]);
  ------------------
  |  Branch (115:22): [True: 4, False: 0]
  ------------------
  116|      4|			break;
  117|      2|		case PROPOSAL_MAC_ALGS_CTOS:
  ------------------
  |  Branch (117:3): [True: 2, False: 18]
  ------------------
  118|      4|		case PROPOSAL_MAC_ALGS_STOC:
  ------------------
  |  Branch (118:3): [True: 2, False: 18]
  ------------------
  119|      4|			prop[i]  = xstrdup(macs ? macs : defprop[i]);
  ------------------
  |  Branch (119:23): [True: 4, False: 0]
  ------------------
  120|      4|			break;
  121|      2|		case PROPOSAL_COMP_ALGS_CTOS:
  ------------------
  |  Branch (121:3): [True: 2, False: 18]
  ------------------
  122|      4|		case PROPOSAL_COMP_ALGS_STOC:
  ------------------
  |  Branch (122:3): [True: 2, False: 18]
  ------------------
  123|      4|			prop[i] = xstrdup(comp ? comp : defprop[i]);
  ------------------
  |  Branch (123:22): [True: 4, False: 0]
  ------------------
  124|      4|			break;
  125|      2|		case PROPOSAL_SERVER_HOST_KEY_ALGS:
  ------------------
  |  Branch (125:3): [True: 2, False: 18]
  ------------------
  126|      2|			prop[i] = xstrdup(hkalgs ? hkalgs : defprop[i]);
  ------------------
  |  Branch (126:22): [True: 2, False: 0]
  ------------------
  127|      2|			break;
  128|      4|		default:
  ------------------
  |  Branch (128:3): [True: 4, False: 16]
  ------------------
  129|      4|			prop[i] = xstrdup(defprop[i]);
  130|     20|		}
  131|     20|	}
  132|      2|	free(cp);
  133|      2|}
kex_proposal_free_entries:
  137|      4|{
  138|      4|	u_int i;
  139|       |
  140|     44|	for (i = 0; i < PROPOSAL_MAX; i++)
  ------------------
  |  Branch (140:14): [True: 40, False: 4]
  ------------------
  141|     40|		free(prop[i]);
  142|      4|}
kex_prop2buf:
  147|      6|{
  148|      6|	u_int i;
  149|      6|	int r;
  150|       |
  151|      6|	sshbuf_reset(b);
  152|       |
  153|       |	/*
  154|       |	 * add a dummy cookie, the cookie will be overwritten by
  155|       |	 * kex_send_kexinit(), each time a kexinit is set
  156|       |	 */
  157|    102|	for (i = 0; i < KEX_COOKIE_LEN; i++) {
  ------------------
  |  |   44|    102|#define KEX_COOKIE_LEN	16
  ------------------
  |  Branch (157:14): [True: 96, False: 6]
  ------------------
  158|     96|		if ((r = sshbuf_put_u8(b, 0)) != 0)
  ------------------
  |  Branch (158:7): [True: 0, False: 96]
  ------------------
  159|      0|			return r;
  160|     96|	}
  161|     66|	for (i = 0; i < PROPOSAL_MAX; i++) {
  ------------------
  |  Branch (161:14): [True: 60, False: 6]
  ------------------
  162|     60|		if ((r = sshbuf_put_cstring(b, proposal[i])) != 0)
  ------------------
  |  Branch (162:7): [True: 0, False: 60]
  ------------------
  163|      0|			return r;
  164|     60|	}
  165|      6|	if ((r = sshbuf_put_u8(b, 0)) != 0 ||	/* first_kex_packet_follows */
  ------------------
  |  Branch (165:6): [True: 0, False: 6]
  ------------------
  166|      6|	    (r = sshbuf_put_u32(b, 0)) != 0)	/* uint32 reserved */
  ------------------
  |  Branch (166:6): [True: 0, False: 6]
  ------------------
  167|      0|		return r;
  168|      6|	return 0;
  169|      6|}
kex_buf2prop:
  174|      8|{
  175|      8|	struct sshbuf *b = NULL;
  176|      8|	u_char v;
  177|      8|	u_int i;
  178|      8|	char **proposal = NULL;
  179|      8|	int r;
  180|       |
  181|      8|	*propp = NULL;
  182|      8|	if ((proposal = calloc(PROPOSAL_MAX, sizeof(char *))) == NULL)
  ------------------
  |  Branch (182:6): [True: 0, False: 8]
  ------------------
  183|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  184|      8|	if ((b = sshbuf_fromb(raw)) == NULL) {
  ------------------
  |  Branch (184:6): [True: 0, False: 8]
  ------------------
  185|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  186|      0|		goto out;
  187|      0|	}
  188|      8|	if ((r = sshbuf_consume(b, KEX_COOKIE_LEN)) != 0) { /* skip cookie */
  ------------------
  |  |   44|      8|#define KEX_COOKIE_LEN	16
  ------------------
  |  Branch (188:6): [True: 0, False: 8]
  ------------------
  189|      0|		error_fr(r, "consume cookie");
  ------------------
  |  |  145|      0|#define error_fr(r, ...)	sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), __VA_ARGS__)
  ------------------
  190|      0|		goto out;
  191|      0|	}
  192|       |	/* extract kex init proposal strings */
  193|     88|	for (i = 0; i < PROPOSAL_MAX; i++) {
  ------------------
  |  Branch (193:14): [True: 80, False: 8]
  ------------------
  194|     80|		if ((r = sshbuf_get_cstring(b, &(proposal[i]), NULL)) != 0) {
  ------------------
  |  Branch (194:7): [True: 0, False: 80]
  ------------------
  195|      0|			error_fr(r, "parse proposal %u", i);
  ------------------
  |  |  145|      0|#define error_fr(r, ...)	sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), __VA_ARGS__)
  ------------------
  196|      0|			goto out;
  197|      0|		}
  198|     80|		debug2("%s: %s", proposal_names[i], proposal[i]);
  ------------------
  |  |  110|     80|#define debug2(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  199|     80|	}
  200|       |	/* first kex follows / reserved */
  201|      8|	if ((r = sshbuf_get_u8(b, &v)) != 0 ||	/* first_kex_follows */
  ------------------
  |  Branch (201:6): [True: 0, False: 8]
  ------------------
  202|      8|	    (r = sshbuf_get_u32(b, &i)) != 0) {	/* reserved */
  ------------------
  |  Branch (202:6): [True: 0, False: 8]
  ------------------
  203|      0|		error_fr(r, "parse");
  ------------------
  |  |  145|      0|#define error_fr(r, ...)	sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), __VA_ARGS__)
  ------------------
  204|      0|		goto out;
  205|      0|	}
  206|      8|	if (first_kex_follows != NULL)
  ------------------
  |  Branch (206:6): [True: 2, False: 6]
  ------------------
  207|      2|		*first_kex_follows = v;
  208|      8|	debug2("first_kex_follows %d ", v);
  ------------------
  |  |  110|      8|#define debug2(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  209|      8|	debug2("reserved %u ", i);
  ------------------
  |  |  110|      8|#define debug2(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  210|      8|	r = 0;
  211|      8|	*propp = proposal;
  212|      8| out:
  213|      8|	if (r != 0 && proposal != NULL)
  ------------------
  |  Branch (213:6): [True: 0, False: 8]
  |  Branch (213:16): [True: 0, False: 0]
  ------------------
  214|      0|		kex_prop_free(proposal);
  215|      8|	sshbuf_free(b);
  216|      8|	return r;
  217|      8|}
kex_prop_free:
  221|      6|{
  222|      6|	u_int i;
  223|       |
  224|      6|	if (proposal == NULL)
  ------------------
  |  Branch (224:6): [True: 0, False: 6]
  ------------------
  225|      0|		return;
  226|     66|	for (i = 0; i < PROPOSAL_MAX; i++)
  ------------------
  |  Branch (226:14): [True: 60, False: 6]
  ------------------
  227|     60|		free(proposal[i]);
  228|      6|	free(proposal);
  229|      6|}
kex_check_warn_weak_crypto:
  301|      2|{
  302|      2|	char remote_id[512];
  303|      2|	int rekeyed = 0;
  304|       |
  305|      2|	if (ssh == NULL || ssh->kex == NULL || ssh->kex->name == NULL ||
  ------------------
  |  Branch (305:6): [True: 0, False: 2]
  |  Branch (305:21): [True: 0, False: 2]
  |  Branch (305:41): [True: 0, False: 2]
  ------------------
  306|      2|	    !ssh->kex->warn_weak_crypto || ssh->kex->non_pq_kex_warned)
  ------------------
  |  Branch (306:6): [True: 2, False: 0]
  |  Branch (306:37): [True: 0, False: 0]
  ------------------
  307|      2|		return;
  308|      0|	if (kex_is_pq_from_name(ssh->kex->name)) {
  ------------------
  |  Branch (308:6): [True: 0, False: 0]
  ------------------
  309|      0|		ssh->kex->pq_kex_negotiated = 1;
  310|      0|		return;
  311|      0|	}
  312|       |
  313|      0|	if (ssh->kex->pq_kex_negotiated)
  ------------------
  |  Branch (313:6): [True: 0, False: 0]
  ------------------
  314|      0|		rekeyed = 1;
  315|      0|	if (!rekeyed && !ssh->kex->server)
  ------------------
  |  Branch (315:6): [True: 0, False: 0]
  |  Branch (315:18): [True: 0, False: 0]
  ------------------
  316|      0|		return; /* client logs initial KEX warning separately */
  317|       |
  318|      0|	sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id));
  319|       |	logit("WARNING: %sconnection%s%s is not using a post-quantum "
  ------------------
  |  |  113|      0|#define logit(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (113:86): [True: 0, False: 0]
  |  |  |  Branch (113:86): [True: 0, False: 0]
  |  |  |  Branch (113:86): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  320|      0|	    "key exchange algorithm: \"%s\"", rekeyed ? "rekeyed " : "",
  321|      0|	    ssh->kex->server ? " from " : "",
  322|      0|	    ssh->kex->server ? remote_id : "", ssh->kex->name);
  323|      0|	ssh->kex->non_pq_kex_warned = 1;
  324|      0|}
kex_server_update_ext_info:
  406|    331|{
  407|    331|	int r;
  408|       |
  409|    331|	if ((ssh->kex->flags & KEX_HAS_EXT_INFO_IN_AUTH) == 0)
  ------------------
  |  |  111|    331|#define KEX_HAS_EXT_INFO_IN_AUTH	0x0040
  ------------------
  |  Branch (409:6): [True: 331, False: 0]
  ------------------
  410|    331|		return 0;
  411|       |
  412|      0|	debug_f("Sending SSH2_MSG_EXT_INFO");
  ------------------
  |  |  122|      0|#define debug_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  413|      0|	if ((r = sshpkt_start(ssh, SSH2_MSG_EXT_INFO)) != 0 ||
  ------------------
  |  |   88|      0|#define SSH2_MSG_EXT_INFO				7
  ------------------
  |  Branch (413:6): [True: 0, False: 0]
  ------------------
  414|      0|	    (r = sshpkt_put_u32(ssh, 1)) != 0 ||
  ------------------
  |  Branch (414:6): [True: 0, False: 0]
  ------------------
  415|      0|	    (r = sshpkt_put_cstring(ssh, "server-sig-algs")) != 0 ||
  ------------------
  |  Branch (415:6): [True: 0, False: 0]
  ------------------
  416|      0|	    (r = sshpkt_put_cstring(ssh, ssh->kex->server_sig_algs)) != 0 ||
  ------------------
  |  Branch (416:6): [True: 0, False: 0]
  ------------------
  417|      0|	    (r = sshpkt_send(ssh)) != 0) {
  ------------------
  |  Branch (417:6): [True: 0, False: 0]
  ------------------
  418|      0|		error_f("send EXT_INFO");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  419|      0|		return r;
  420|      0|	}
  421|      0|	return 0;
  422|      0|}
kex_send_newkeys:
  426|      2|{
  427|      2|	int r;
  428|       |
  429|      2|	kex_reset_dispatch(ssh);
  430|      2|	if ((r = sshpkt_start(ssh, SSH2_MSG_NEWKEYS)) != 0 ||
  ------------------
  |  |   94|      2|#define SSH2_MSG_NEWKEYS				21
  ------------------
  |  Branch (430:6): [True: 0, False: 2]
  ------------------
  431|      2|	    (r = sshpkt_send(ssh)) != 0)
  ------------------
  |  Branch (431:6): [True: 0, False: 2]
  ------------------
  432|      0|		return r;
  433|      2|	debug("SSH2_MSG_NEWKEYS sent");
  ------------------
  |  |  111|      2|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  434|      2|	ssh_dispatch_set(ssh, SSH2_MSG_NEWKEYS, &kex_input_newkeys);
  ------------------
  |  |   94|      2|#define SSH2_MSG_NEWKEYS				21
  ------------------
  435|      2|	if ((r = kex_maybe_send_ext_info(ssh)) != 0)
  ------------------
  |  Branch (435:6): [True: 0, False: 2]
  ------------------
  436|      0|		return r;
  437|      2|	debug("expecting SSH2_MSG_NEWKEYS");
  ------------------
  |  |  111|      2|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  438|      2|	return 0;
  439|      2|}
kex_send_kexinit:
  610|      2|{
  611|      2|	u_char *cookie;
  612|      2|	struct kex *kex = ssh->kex;
  613|      2|	int r;
  614|       |
  615|      2|	if (kex == NULL) {
  ------------------
  |  Branch (615:6): [True: 0, False: 2]
  ------------------
  616|      0|		error_f("no kex");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  617|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  618|      0|	}
  619|      2|	if (kex->flags & KEX_INIT_SENT)
  ------------------
  |  |  105|      2|#define KEX_INIT_SENT			0x0001
  ------------------
  |  Branch (619:6): [True: 0, False: 2]
  ------------------
  620|      0|		return 0;
  621|      2|	kex->done = 0;
  622|       |
  623|       |	/* generate a random cookie */
  624|      2|	if (sshbuf_len(kex->my) < KEX_COOKIE_LEN) {
  ------------------
  |  |   44|      2|#define KEX_COOKIE_LEN	16
  ------------------
  |  Branch (624:6): [True: 0, False: 2]
  ------------------
  625|      0|		error_f("bad kex length: %zu < %d",
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  626|      0|		    sshbuf_len(kex->my), KEX_COOKIE_LEN);
  627|      0|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  628|      0|	}
  629|      2|	if ((cookie = sshbuf_mutable_ptr(kex->my)) == NULL) {
  ------------------
  |  Branch (629:6): [True: 0, False: 2]
  ------------------
  630|      0|		error_f("buffer error");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  631|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  632|      0|	}
  633|      2|	arc4random_buf(cookie, KEX_COOKIE_LEN);
  ------------------
  |  |   44|      2|#define KEX_COOKIE_LEN	16
  ------------------
  634|       |
  635|      2|	if ((r = sshpkt_start(ssh, SSH2_MSG_KEXINIT)) != 0 ||
  ------------------
  |  |   93|      2|#define SSH2_MSG_KEXINIT				20
  ------------------
  |  Branch (635:6): [True: 0, False: 2]
  ------------------
  636|      2|	    (r = sshpkt_putb(ssh, kex->my)) != 0 ||
  ------------------
  |  Branch (636:6): [True: 0, False: 2]
  ------------------
  637|      2|	    (r = sshpkt_send(ssh)) != 0) {
  ------------------
  |  Branch (637:6): [True: 0, False: 2]
  ------------------
  638|      0|		error_fr(r, "compose reply");
  ------------------
  |  |  145|      0|#define error_fr(r, ...)	sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), __VA_ARGS__)
  ------------------
  639|      0|		return r;
  640|      0|	}
  641|      2|	debug("SSH2_MSG_KEXINIT sent");
  ------------------
  |  |  111|      2|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  642|      2|	kex->flags |= KEX_INIT_SENT;
  ------------------
  |  |  105|      2|#define KEX_INIT_SENT			0x0001
  ------------------
  643|      2|	return 0;
  644|      2|}
kex_input_kexinit:
  648|      2|{
  649|      2|	struct kex *kex = ssh->kex;
  650|      2|	const u_char *ptr;
  651|      2|	u_int i;
  652|      2|	size_t dlen;
  653|      2|	int r;
  654|       |
  655|      2|	debug("SSH2_MSG_KEXINIT received");
  ------------------
  |  |  111|      2|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  656|      2|	if (kex == NULL) {
  ------------------
  |  Branch (656:6): [True: 0, False: 2]
  ------------------
  657|      0|		error_f("no kex");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  658|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  659|      0|	}
  660|      2|	free(kex->name);
  661|      2|	kex->name = NULL;
  662|      2|	if ((kex->flags & KEX_INIT_RECVD) != 0) {
  ------------------
  |  |  113|      2|#define KEX_INIT_RECVD			0x0100
  ------------------
  |  Branch (662:6): [True: 0, False: 2]
  ------------------
  663|      0|		ssh_packet_disconnect(ssh,
  664|      0|		    "multiple KEXINIT received from peer");
  665|      0|	}
  666|      2|	kex->flags |= KEX_INIT_RECVD;
  ------------------
  |  |  113|      2|#define KEX_INIT_RECVD			0x0100
  ------------------
  667|      2|	ssh_dispatch_set(ssh, SSH2_MSG_KEXINIT, &kex_protocol_error);
  ------------------
  |  |   93|      2|#define SSH2_MSG_KEXINIT				20
  ------------------
  668|      2|	ptr = sshpkt_ptr(ssh, &dlen);
  669|      2|	if ((r = sshbuf_put(kex->peer, ptr, dlen)) != 0)
  ------------------
  |  Branch (669:6): [True: 0, False: 2]
  ------------------
  670|      0|		return r;
  671|       |
  672|       |	/* discard packet */
  673|     34|	for (i = 0; i < KEX_COOKIE_LEN; i++) {
  ------------------
  |  |   44|     34|#define KEX_COOKIE_LEN	16
  ------------------
  |  Branch (673:14): [True: 32, False: 2]
  ------------------
  674|     32|		if ((r = sshpkt_get_u8(ssh, NULL)) != 0) {
  ------------------
  |  Branch (674:7): [True: 0, False: 32]
  ------------------
  675|      0|			error_fr(r, "discard cookie");
  ------------------
  |  |  145|      0|#define error_fr(r, ...)	sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), __VA_ARGS__)
  ------------------
  676|      0|			return r;
  677|      0|		}
  678|     32|	}
  679|     22|	for (i = 0; i < PROPOSAL_MAX; i++) {
  ------------------
  |  Branch (679:14): [True: 20, False: 2]
  ------------------
  680|     20|		if ((r = sshpkt_get_string(ssh, NULL, NULL)) != 0) {
  ------------------
  |  Branch (680:7): [True: 0, False: 20]
  ------------------
  681|      0|			error_fr(r, "discard proposal");
  ------------------
  |  |  145|      0|#define error_fr(r, ...)	sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), __VA_ARGS__)
  ------------------
  682|      0|			return r;
  683|      0|		}
  684|     20|	}
  685|       |	/*
  686|       |	 * XXX RFC4253 sec 7: "each side MAY guess" - currently no supported
  687|       |	 * KEX method has the server move first, but a server might be using
  688|       |	 * a custom method or one that we otherwise don't support. We should
  689|       |	 * be prepared to remember first_kex_follows here so we can eat a
  690|       |	 * packet later.
  691|       |	 * XXX2 - RFC4253 is kind of ambiguous on what first_kex_follows means
  692|       |	 * for cases where the server *doesn't* go first. I guess we should
  693|       |	 * ignore it when it is set for these cases, which is what we do now.
  694|       |	 */
  695|      2|	if ((r = sshpkt_get_u8(ssh, NULL)) != 0 ||	/* first_kex_follows */
  ------------------
  |  Branch (695:6): [True: 0, False: 2]
  ------------------
  696|      2|	    (r = sshpkt_get_u32(ssh, NULL)) != 0 ||	/* reserved */
  ------------------
  |  Branch (696:6): [True: 0, False: 2]
  ------------------
  697|      2|	    (r = sshpkt_get_end(ssh)) != 0)
  ------------------
  |  Branch (697:6): [True: 0, False: 2]
  ------------------
  698|      0|			return r;
  699|       |
  700|      2|	if (!(kex->flags & KEX_INIT_SENT))
  ------------------
  |  |  105|      2|#define KEX_INIT_SENT			0x0001
  ------------------
  |  Branch (700:6): [True: 0, False: 2]
  ------------------
  701|      0|		if ((r = kex_send_kexinit(ssh)) != 0)
  ------------------
  |  Branch (701:7): [True: 0, False: 0]
  ------------------
  702|      0|			return r;
  703|      2|	if ((r = kex_choose_conf(ssh, seq)) != 0)
  ------------------
  |  Branch (703:6): [True: 0, False: 2]
  ------------------
  704|      0|		return r;
  705|       |
  706|      2|	if (kex->kex_type < KEX_MAX && kex->kex[kex->kex_type] != NULL)
  ------------------
  |  Branch (706:6): [True: 2, False: 0]
  |  Branch (706:33): [True: 2, False: 0]
  ------------------
  707|      2|		return (kex->kex[kex->kex_type])(ssh);
  708|       |
  709|      0|	error_f("unknown kex type %u", kex->kex_type);
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  710|      0|	return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  711|      2|}
kex_new:
  715|      2|{
  716|      2|	struct kex *kex;
  717|       |
  718|      2|	if ((kex = calloc(1, sizeof(*kex))) == NULL ||
  ------------------
  |  Branch (718:6): [True: 0, False: 2]
  ------------------
  719|      2|	    (kex->peer = sshbuf_new()) == NULL ||
  ------------------
  |  Branch (719:6): [True: 0, False: 2]
  ------------------
  720|      2|	    (kex->my = sshbuf_new()) == NULL ||
  ------------------
  |  Branch (720:6): [True: 0, False: 2]
  ------------------
  721|      2|	    (kex->client_version = sshbuf_new()) == NULL ||
  ------------------
  |  Branch (721:6): [True: 0, False: 2]
  ------------------
  722|      2|	    (kex->server_version = sshbuf_new()) == NULL ||
  ------------------
  |  Branch (722:6): [True: 0, False: 2]
  ------------------
  723|      2|	    (kex->session_id = sshbuf_new()) == NULL) {
  ------------------
  |  Branch (723:6): [True: 0, False: 2]
  ------------------
  724|      0|		kex_free(kex);
  725|      0|		return NULL;
  726|      0|	}
  727|      2|	return kex;
  728|      2|}
kex_ready:
  793|      2|{
  794|      2|	int r;
  795|       |
  796|      2|	if ((r = kex_prop2buf(ssh->kex->my, proposal)) != 0)
  ------------------
  |  Branch (796:6): [True: 0, False: 2]
  ------------------
  797|      0|		return r;
  798|      2|	ssh->kex->flags = KEX_INITIAL;
  ------------------
  |  |  106|      2|#define KEX_INITIAL			0x0002
  ------------------
  799|      2|	kex_reset_dispatch(ssh);
  800|      2|	ssh_dispatch_set(ssh, SSH2_MSG_KEXINIT, &kex_input_kexinit);
  ------------------
  |  |   93|      2|#define SSH2_MSG_KEXINIT				20
  ------------------
  801|      2|	return 0;
  802|      2|}
kex_derive_keys:
 1169|      2|{
 1170|      2|	struct kex *kex = ssh->kex;
 1171|      2|	u_char *keys[NKEYS];
 1172|      2|	u_int i, j, mode, ctos;
 1173|      2|	int r;
 1174|       |
 1175|       |	/* save initial hash as session id */
 1176|      2|	if ((kex->flags & KEX_INITIAL) != 0) {
  ------------------
  |  |  106|      2|#define KEX_INITIAL			0x0002
  ------------------
  |  Branch (1176:6): [True: 2, False: 0]
  ------------------
 1177|      2|		if (sshbuf_len(kex->session_id) != 0) {
  ------------------
  |  Branch (1177:7): [True: 0, False: 2]
  ------------------
 1178|      0|			error_f("already have session ID at kex");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
 1179|      0|			return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 1180|      0|		}
 1181|      2|		if ((r = sshbuf_put(kex->session_id, hash, hashlen)) != 0)
  ------------------
  |  Branch (1181:7): [True: 0, False: 2]
  ------------------
 1182|      0|			return r;
 1183|      2|	} else if (sshbuf_len(kex->session_id) == 0) {
  ------------------
  |  Branch (1183:13): [True: 0, False: 0]
  ------------------
 1184|      0|		error_f("no session ID in rekex");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
 1185|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 1186|      0|	}
 1187|     14|	for (i = 0; i < NKEYS; i++) {
  ------------------
  |  | 1165|     14|#define NKEYS	6
  ------------------
  |  Branch (1187:14): [True: 12, False: 2]
  ------------------
 1188|     12|		if ((r = derive_key(ssh, 'A'+i, kex->we_need, hash, hashlen,
  ------------------
  |  Branch (1188:7): [True: 0, False: 12]
  ------------------
 1189|     12|		    shared_secret, &keys[i])) != 0) {
 1190|      0|			for (j = 0; j < i; j++)
  ------------------
  |  Branch (1190:16): [True: 0, False: 0]
  ------------------
 1191|      0|				free(keys[j]);
 1192|      0|			return r;
 1193|      0|		}
 1194|     12|	}
 1195|      6|	for (mode = 0; mode < MODE_MAX; mode++) {
  ------------------
  |  Branch (1195:17): [True: 4, False: 2]
  ------------------
 1196|      4|		ctos = (!kex->server && mode == MODE_OUT) ||
  ------------------
  |  Branch (1196:11): [True: 2, False: 2]
  |  Branch (1196:27): [True: 1, False: 1]
  ------------------
 1197|      3|		    (kex->server && mode == MODE_IN);
  ------------------
  |  Branch (1197:8): [True: 2, False: 1]
  |  Branch (1197:23): [True: 1, False: 1]
  ------------------
 1198|      4|		kex->newkeys[mode]->enc.iv  = keys[ctos ? 0 : 1];
  ------------------
  |  Branch (1198:38): [True: 2, False: 2]
  ------------------
 1199|      4|		kex->newkeys[mode]->enc.key = keys[ctos ? 2 : 3];
  ------------------
  |  Branch (1199:38): [True: 2, False: 2]
  ------------------
 1200|      4|		kex->newkeys[mode]->mac.key = keys[ctos ? 4 : 5];
  ------------------
  |  Branch (1200:38): [True: 2, False: 2]
  ------------------
 1201|      4|	}
 1202|      2|	return 0;
 1203|      2|}
kex_load_hostkey:
 1207|      1|{
 1208|      1|	struct kex *kex = ssh->kex;
 1209|       |
 1210|      1|	*pubp = NULL;
 1211|      1|	*prvp = NULL;
 1212|      1|	if (kex->load_host_public_key == NULL ||
  ------------------
  |  Branch (1212:6): [True: 0, False: 1]
  ------------------
 1213|      1|	    kex->load_host_private_key == NULL) {
  ------------------
  |  Branch (1213:6): [True: 0, False: 1]
  ------------------
 1214|      0|		error_f("missing hostkey loader");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
 1215|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
 1216|      0|	}
 1217|      1|	*pubp = kex->load_host_public_key(kex->hostkey_type,
 1218|      1|	    kex->hostkey_nid, ssh);
 1219|      1|	*prvp = kex->load_host_private_key(kex->hostkey_type,
 1220|      1|	    kex->hostkey_nid, ssh);
 1221|      1|	if (*pubp == NULL)
  ------------------
  |  Branch (1221:6): [True: 0, False: 1]
  ------------------
 1222|      0|		return SSH_ERR_NO_HOSTKEY_LOADED;
  ------------------
  |  |   60|      0|#define SSH_ERR_NO_HOSTKEY_LOADED		-36
  ------------------
 1223|      1|	return 0;
 1224|      1|}
kex_verify_host_key:
 1228|      1|{
 1229|      1|	struct kex *kex = ssh->kex;
 1230|       |
 1231|      1|	if (kex->verify_host_key == NULL) {
  ------------------
  |  Branch (1231:6): [True: 0, False: 1]
  ------------------
 1232|      0|		error_f("missing hostkey verifier");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
 1233|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
 1234|      0|	}
 1235|      1|	if (server_host_key->type != kex->hostkey_type ||
  ------------------
  |  Branch (1235:6): [True: 0, False: 1]
  ------------------
 1236|      1|	    (kex->hostkey_type == KEY_ECDSA &&
  ------------------
  |  Branch (1236:7): [True: 0, False: 1]
  ------------------
 1237|      0|	    server_host_key->ecdsa_nid != kex->hostkey_nid))
  ------------------
  |  Branch (1237:6): [True: 0, False: 0]
  ------------------
 1238|      0|		return SSH_ERR_KEY_TYPE_MISMATCH;
  ------------------
  |  |   37|      0|#define SSH_ERR_KEY_TYPE_MISMATCH		-13
  ------------------
 1239|      1|	if (kex->verify_host_key(server_host_key, ssh) == -1)
  ------------------
  |  Branch (1239:6): [True: 0, False: 1]
  ------------------
 1240|      0|		return  SSH_ERR_SIGNATURE_INVALID;
  ------------------
  |  |   45|      0|#define SSH_ERR_SIGNATURE_INVALID		-21
  ------------------
 1241|      1|	return 0;
 1242|      1|}
kex.c:kex_reset_dispatch:
  251|      4|{
  252|      4|	ssh_dispatch_range(ssh, SSH2_MSG_TRANSPORT_MIN,
  ------------------
  |  |   65|      4|#define SSH2_MSG_TRANSPORT_MIN				1
  ------------------
  253|      4|	    SSH2_MSG_TRANSPORT_MAX, &kex_protocol_error);
  ------------------
  |  |   66|      4|#define SSH2_MSG_TRANSPORT_MAX				49
  ------------------
  254|      4|}
kex.c:kex_maybe_send_ext_info:
  369|      2|{
  370|      2|	int r;
  371|      2|	struct sshbuf *m = NULL;
  372|       |
  373|      2|	if ((ssh->kex->flags & KEX_INITIAL) == 0)
  ------------------
  |  |  106|      2|#define KEX_INITIAL			0x0002
  ------------------
  |  Branch (373:6): [True: 0, False: 2]
  ------------------
  374|      0|		return 0;
  375|      2|	if (!ssh->kex->ext_info_c && !ssh->kex->ext_info_s)
  ------------------
  |  Branch (375:6): [True: 1, False: 1]
  |  Branch (375:31): [True: 0, False: 1]
  ------------------
  376|      0|		return 0;
  377|       |
  378|       |	/* Compose EXT_INFO packet. */
  379|      2|	if ((m = sshbuf_new()) == NULL)
  ------------------
  |  Branch (379:6): [True: 0, False: 2]
  ------------------
  380|      0|		fatal_f("sshbuf_new failed");
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  381|      2|	if (ssh->kex->ext_info_c &&
  ------------------
  |  Branch (381:6): [True: 1, False: 1]
  ------------------
  382|      1|	    (r = kex_compose_ext_info_server(ssh, m)) != 0)
  ------------------
  |  Branch (382:6): [True: 0, False: 1]
  ------------------
  383|      0|		goto fail;
  384|      2|	if (ssh->kex->ext_info_s &&
  ------------------
  |  Branch (384:6): [True: 1, False: 1]
  ------------------
  385|      1|	    (r = kex_compose_ext_info_client(ssh, m)) != 0)
  ------------------
  |  Branch (385:6): [True: 0, False: 1]
  ------------------
  386|      0|		goto fail;
  387|       |
  388|       |	/* Send the actual KEX_INFO packet */
  389|      2|	debug("Sending SSH2_MSG_EXT_INFO");
  ------------------
  |  |  111|      2|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  390|      2|	if ((r = sshpkt_start(ssh, SSH2_MSG_EXT_INFO)) != 0 ||
  ------------------
  |  |   88|      2|#define SSH2_MSG_EXT_INFO				7
  ------------------
  |  Branch (390:6): [True: 0, False: 2]
  ------------------
  391|      2|	    (r = sshpkt_putb(ssh, m)) != 0 ||
  ------------------
  |  Branch (391:6): [True: 0, False: 2]
  ------------------
  392|      2|	    (r = sshpkt_send(ssh)) != 0) {
  ------------------
  |  Branch (392:6): [True: 0, False: 2]
  ------------------
  393|      0|		error_f("send EXT_INFO");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  394|      0|		goto fail;
  395|      0|	}
  396|       |
  397|      2|	r = 0;
  398|       |
  399|      2| fail:
  400|      2|	sshbuf_free(m);
  401|      2|	return r;
  402|      2|}
kex.c:kex_compose_ext_info_server:
  328|      1|{
  329|      1|	int r;
  330|       |
  331|      1|	if (ssh->kex->server_sig_algs == NULL &&
  ------------------
  |  Branch (331:6): [True: 1, False: 0]
  ------------------
  332|      1|	    (ssh->kex->server_sig_algs = sshkey_alg_list(0, 1, 1, ',')) == NULL)
  ------------------
  |  Branch (332:6): [True: 0, False: 1]
  ------------------
  333|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  334|      1|	if ((r = sshbuf_put_u32(m, 4)) != 0 ||
  ------------------
  |  Branch (334:6): [True: 0, False: 1]
  ------------------
  335|      1|	    (r = sshbuf_put_cstring(m, "server-sig-algs")) != 0 ||
  ------------------
  |  Branch (335:6): [True: 0, False: 1]
  ------------------
  336|      1|	    (r = sshbuf_put_cstring(m, ssh->kex->server_sig_algs)) != 0 ||
  ------------------
  |  Branch (336:6): [True: 0, False: 1]
  ------------------
  337|      1|	    (r = sshbuf_put_cstring(m,
  ------------------
  |  Branch (337:6): [True: 0, False: 1]
  ------------------
  338|      1|	    "publickey-hostbound@openssh.com")) != 0 ||
  339|      1|	    (r = sshbuf_put_cstring(m, "0")) != 0 ||
  ------------------
  |  Branch (339:6): [True: 0, False: 1]
  ------------------
  340|      1|	    (r = sshbuf_put_cstring(m, "ping@openssh.com")) != 0 ||
  ------------------
  |  Branch (340:6): [True: 0, False: 1]
  ------------------
  341|      1|	    (r = sshbuf_put_cstring(m, "0")) != 0 ||
  ------------------
  |  Branch (341:6): [True: 0, False: 1]
  ------------------
  342|      1|	    (r = sshbuf_put_cstring(m, "agent-forward")) != 0 ||
  ------------------
  |  Branch (342:6): [True: 0, False: 1]
  ------------------
  343|      1|	    (r = sshbuf_put_cstring(m, "0")) != 0) {
  ------------------
  |  Branch (343:6): [True: 0, False: 1]
  ------------------
  344|      0|		error_fr(r, "compose");
  ------------------
  |  |  145|      0|#define error_fr(r, ...)	sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), __VA_ARGS__)
  ------------------
  345|      0|		return r;
  346|      0|	}
  347|      1|	return 0;
  348|      1|}
kex.c:kex_compose_ext_info_client:
  352|      1|{
  353|      1|	int r;
  354|       |
  355|      1|	if ((r = sshbuf_put_u32(m, 1)) != 0 ||
  ------------------
  |  Branch (355:6): [True: 0, False: 1]
  ------------------
  356|      1|	    (r = sshbuf_put_cstring(m, "ext-info-in-auth@openssh.com")) != 0 ||
  ------------------
  |  Branch (356:6): [True: 0, False: 1]
  ------------------
  357|      1|	    (r = sshbuf_put_cstring(m, "0")) != 0) {
  ------------------
  |  Branch (357:6): [True: 0, False: 1]
  ------------------
  358|      0|		error_fr(r, "compose");
  ------------------
  |  |  145|      0|#define error_fr(r, ...)	sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), __VA_ARGS__)
  ------------------
  359|      0|		goto out;
  360|      0|	}
  361|       |	/* success */
  362|      1|	r = 0;
  363|      1| out:
  364|      1|	return r;
  365|      1|}
kex.c:kex_input_newkeys:
  563|      2|{
  564|      2|	struct kex *kex = ssh->kex;
  565|      2|	int r, initial = (kex->flags & KEX_INITIAL) != 0;
  ------------------
  |  |  106|      2|#define KEX_INITIAL			0x0002
  ------------------
  566|      2|	char *cp, **prop;
  567|       |
  568|      2|	debug("SSH2_MSG_NEWKEYS received");
  ------------------
  |  |  111|      2|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  569|      2|	if (kex->ext_info_c && initial)
  ------------------
  |  Branch (569:6): [True: 1, False: 1]
  |  Branch (569:25): [True: 1, False: 0]
  ------------------
  570|      1|		ssh_dispatch_set(ssh, SSH2_MSG_EXT_INFO, &kex_input_ext_info);
  ------------------
  |  |   88|      1|#define SSH2_MSG_EXT_INFO				7
  ------------------
  571|      2|	ssh_dispatch_set(ssh, SSH2_MSG_NEWKEYS, &kex_protocol_error);
  ------------------
  |  |   94|      2|#define SSH2_MSG_NEWKEYS				21
  ------------------
  572|      2|	ssh_dispatch_set(ssh, SSH2_MSG_KEXINIT, &kex_input_kexinit);
  ------------------
  |  |   93|      2|#define SSH2_MSG_KEXINIT				20
  ------------------
  573|      2|	if ((r = sshpkt_get_end(ssh)) != 0)
  ------------------
  |  Branch (573:6): [True: 0, False: 2]
  ------------------
  574|      0|		return r;
  575|      2|	if ((r = ssh_set_newkeys(ssh, MODE_IN)) != 0)
  ------------------
  |  Branch (575:6): [True: 0, False: 2]
  ------------------
  576|      0|		return r;
  577|      2|	if (initial) {
  ------------------
  |  Branch (577:6): [True: 2, False: 0]
  ------------------
  578|       |		/* Remove initial KEX signalling from proposal for rekeying */
  579|      2|		if ((r = kex_buf2prop(kex->my, NULL, &prop)) != 0)
  ------------------
  |  Branch (579:7): [True: 0, False: 2]
  ------------------
  580|      0|			return r;
  581|      2|		if ((cp = match_filter_denylist(prop[PROPOSAL_KEX_ALGS],
  ------------------
  |  Branch (581:7): [True: 0, False: 2]
  ------------------
  582|      2|		    kex->server ?
  ------------------
  |  Branch (582:7): [True: 1, False: 1]
  ------------------
  583|      1|		    "ext-info-s,kex-strict-s-v00@openssh.com" :
  584|      2|		    "ext-info-c,kex-strict-c-v00@openssh.com")) == NULL) {
  585|      0|			error_f("match_filter_denylist failed");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  586|      0|			goto fail;
  587|      0|		}
  588|      2|		free(prop[PROPOSAL_KEX_ALGS]);
  589|      2|		prop[PROPOSAL_KEX_ALGS] = cp;
  590|      2|		if ((r = kex_prop2buf(ssh->kex->my, prop)) != 0) {
  ------------------
  |  Branch (590:7): [True: 0, False: 2]
  ------------------
  591|      0|			error_f("kex_prop2buf failed");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  592|      0| fail:
  593|      0|			kex_proposal_free_entries(prop);
  594|      0|			free(prop);
  595|      0|			return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  596|      0|		}
  597|      2|		kex_proposal_free_entries(prop);
  598|      2|		free(prop);
  599|      2|	}
  600|      2|	kex->done = 1;
  601|      2|	kex->flags &= ~KEX_INITIAL;
  ------------------
  |  |  106|      2|#define KEX_INITIAL			0x0002
  ------------------
  602|      2|	sshbuf_reset(kex->peer);
  603|      2|	kex->flags &= ~(KEX_INIT_SENT|KEX_INIT_RECVD);
  ------------------
  |  |  105|      2|#define KEX_INIT_SENT			0x0001
  ------------------
              	kex->flags &= ~(KEX_INIT_SENT|KEX_INIT_RECVD);
  ------------------
  |  |  113|      2|#define KEX_INIT_RECVD			0x0100
  ------------------
  604|      2|	kex_check_warn_weak_crypto(ssh);
  605|      2|	return 0;
  606|      2|}
kex.c:kex_choose_conf:
  970|      2|{
  971|      2|	struct kex *kex = ssh->kex;
  972|      2|	struct newkeys *newkeys;
  973|      2|	char **my = NULL, **peer = NULL;
  974|      2|	char **cprop, **sprop;
  975|      2|	int nenc, nmac, ncomp;
  976|      2|	u_int mode, ctos, need, dh_need, authlen;
  977|      2|	int r, first_kex_follows;
  978|       |
  979|      2|	debug2("local %s KEXINIT proposal", kex->server ? "server" : "client");
  ------------------
  |  |  110|      4|#define debug2(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (110:89): [True: 1, False: 1]
  |  |  ------------------
  ------------------
  980|      2|	if ((r = kex_buf2prop(kex->my, NULL, &my)) != 0)
  ------------------
  |  Branch (980:6): [True: 0, False: 2]
  ------------------
  981|      0|		goto out;
  982|      2|	debug2("peer %s KEXINIT proposal", kex->server ? "client" : "server");
  ------------------
  |  |  110|      4|#define debug2(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (110:89): [True: 1, False: 1]
  |  |  ------------------
  ------------------
  983|      2|	if ((r = kex_buf2prop(kex->peer, &first_kex_follows, &peer)) != 0)
  ------------------
  |  Branch (983:6): [True: 0, False: 2]
  ------------------
  984|      0|		goto out;
  985|       |
  986|      2|	if (kex->server) {
  ------------------
  |  Branch (986:6): [True: 1, False: 1]
  ------------------
  987|      1|		cprop=peer;
  988|      1|		sprop=my;
  989|      1|	} else {
  990|      1|		cprop=my;
  991|      1|		sprop=peer;
  992|      1|	}
  993|       |
  994|       |	/* Check whether peer supports ext_info/kex_strict */
  995|      2|	if ((kex->flags & KEX_INITIAL) != 0) {
  ------------------
  |  |  106|      2|#define KEX_INITIAL			0x0002
  ------------------
  |  Branch (995:6): [True: 2, False: 0]
  ------------------
  996|      2|		if (kex->server) {
  ------------------
  |  Branch (996:7): [True: 1, False: 1]
  ------------------
  997|      1|			kex->ext_info_c = kexalgs_contains(peer, "ext-info-c");
  998|      1|			kex->kex_strict = kexalgs_contains(peer,
  999|      1|			    "kex-strict-c-v00@openssh.com");
 1000|      1|		} else {
 1001|      1|			kex->ext_info_s = kexalgs_contains(peer, "ext-info-s");
 1002|      1|			kex->kex_strict = kexalgs_contains(peer,
 1003|      1|			    "kex-strict-s-v00@openssh.com");
 1004|      1|		}
 1005|      2|		if (kex->kex_strict) {
  ------------------
  |  Branch (1005:7): [True: 2, False: 0]
  ------------------
 1006|      2|			debug3_f("will use strict KEX ordering");
  ------------------
  |  |  120|      2|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
 1007|      2|			if (seq != 0)
  ------------------
  |  Branch (1007:8): [True: 0, False: 2]
  ------------------
 1008|      0|				ssh_packet_disconnect(ssh,
 1009|      0|				    "strict KEX violation: "
 1010|      0|				    "KEXINIT was not the first packet");
 1011|      2|		}
 1012|      2|	}
 1013|       |
 1014|       |	/* Check whether client supports rsa-sha2 algorithms */
 1015|      2|	if (kex->server && (kex->flags & KEX_INITIAL)) {
  ------------------
  |  |  106|      1|#define KEX_INITIAL			0x0002
  ------------------
  |  Branch (1015:6): [True: 1, False: 1]
  |  Branch (1015:21): [True: 1, False: 0]
  ------------------
 1016|      1|		if (kex_has_any_alg(peer[PROPOSAL_SERVER_HOST_KEY_ALGS],
  ------------------
  |  Branch (1016:7): [True: 0, False: 1]
  ------------------
 1017|      1|		    "rsa-sha2-256,rsa-sha2-256-cert-v01@openssh.com"))
 1018|      0|			kex->flags |= KEX_RSA_SHA2_256_SUPPORTED;
  ------------------
  |  |  108|      0|#define KEX_RSA_SHA2_256_SUPPORTED	0x0008 /* only set in server for now */
  ------------------
 1019|      1|		if (kex_has_any_alg(peer[PROPOSAL_SERVER_HOST_KEY_ALGS],
  ------------------
  |  Branch (1019:7): [True: 0, False: 1]
  ------------------
 1020|      1|		    "rsa-sha2-512,rsa-sha2-512-cert-v01@openssh.com"))
 1021|      0|			kex->flags |= KEX_RSA_SHA2_512_SUPPORTED;
  ------------------
  |  |  109|      0|#define KEX_RSA_SHA2_512_SUPPORTED	0x0010 /* only set in server for now */
  ------------------
 1022|      1|	}
 1023|       |
 1024|       |	/* Algorithm Negotiation */
 1025|      2|	if ((r = choose_kex(kex, cprop[PROPOSAL_KEX_ALGS],
  ------------------
  |  Branch (1025:6): [True: 0, False: 2]
  ------------------
 1026|      2|	    sprop[PROPOSAL_KEX_ALGS])) != 0) {
 1027|      0|		kex->failed_choice = peer[PROPOSAL_KEX_ALGS];
 1028|      0|		peer[PROPOSAL_KEX_ALGS] = NULL;
 1029|      0|		goto out;
 1030|      0|	}
 1031|      2|	if ((r = choose_hostkeyalg(kex, cprop[PROPOSAL_SERVER_HOST_KEY_ALGS],
  ------------------
  |  Branch (1031:6): [True: 0, False: 2]
  ------------------
 1032|      2|	    sprop[PROPOSAL_SERVER_HOST_KEY_ALGS])) != 0) {
 1033|      0|		kex->failed_choice = peer[PROPOSAL_SERVER_HOST_KEY_ALGS];
 1034|      0|		peer[PROPOSAL_SERVER_HOST_KEY_ALGS] = NULL;
 1035|      0|		goto out;
 1036|      0|	}
 1037|      6|	for (mode = 0; mode < MODE_MAX; mode++) {
  ------------------
  |  Branch (1037:17): [True: 4, False: 2]
  ------------------
 1038|      4|		if ((newkeys = calloc(1, sizeof(*newkeys))) == NULL) {
  ------------------
  |  Branch (1038:7): [True: 0, False: 4]
  ------------------
 1039|      0|			r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 1040|      0|			goto out;
 1041|      0|		}
 1042|      4|		kex->newkeys[mode] = newkeys;
 1043|      4|		ctos = (!kex->server && mode == MODE_OUT) ||
  ------------------
  |  Branch (1043:11): [True: 2, False: 2]
  |  Branch (1043:27): [True: 1, False: 1]
  ------------------
 1044|      3|		    (kex->server && mode == MODE_IN);
  ------------------
  |  Branch (1044:8): [True: 2, False: 1]
  |  Branch (1044:23): [True: 1, False: 1]
  ------------------
 1045|      4|		nenc  = ctos ? PROPOSAL_ENC_ALGS_CTOS  : PROPOSAL_ENC_ALGS_STOC;
  ------------------
  |  Branch (1045:11): [True: 2, False: 2]
  ------------------
 1046|      4|		nmac  = ctos ? PROPOSAL_MAC_ALGS_CTOS  : PROPOSAL_MAC_ALGS_STOC;
  ------------------
  |  Branch (1046:11): [True: 2, False: 2]
  ------------------
 1047|      4|		ncomp = ctos ? PROPOSAL_COMP_ALGS_CTOS : PROPOSAL_COMP_ALGS_STOC;
  ------------------
  |  Branch (1047:11): [True: 2, False: 2]
  ------------------
 1048|      4|		if ((r = choose_enc(&newkeys->enc, cprop[nenc],
  ------------------
  |  Branch (1048:7): [True: 0, False: 4]
  ------------------
 1049|      4|		    sprop[nenc])) != 0) {
 1050|      0|			kex->failed_choice = peer[nenc];
 1051|      0|			peer[nenc] = NULL;
 1052|      0|			goto out;
 1053|      0|		}
 1054|      4|		authlen = cipher_authlen(newkeys->enc.cipher);
 1055|       |		/* ignore mac for authenticated encryption */
 1056|      4|		if (authlen == 0 &&
  ------------------
  |  Branch (1056:7): [True: 4, False: 0]
  ------------------
 1057|      4|		    (r = choose_mac(ssh, &newkeys->mac, cprop[nmac],
  ------------------
  |  Branch (1057:7): [True: 0, False: 4]
  ------------------
 1058|      4|		    sprop[nmac])) != 0) {
 1059|      0|			kex->failed_choice = peer[nmac];
 1060|      0|			peer[nmac] = NULL;
 1061|      0|			goto out;
 1062|      0|		}
 1063|      4|		if ((r = choose_comp(&newkeys->comp, cprop[ncomp],
  ------------------
  |  Branch (1063:7): [True: 0, False: 4]
  ------------------
 1064|      4|		    sprop[ncomp])) != 0) {
 1065|      0|			kex->failed_choice = peer[ncomp];
 1066|      0|			peer[ncomp] = NULL;
 1067|      0|			goto out;
 1068|      0|		}
 1069|      4|		debug("kex: %s cipher: %s MAC: %s compression: %s",
  ------------------
  |  |  111|     16|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (111:88): [True: 2, False: 2]
  |  |  |  Branch (111:88): [True: 4, False: 0]
  |  |  ------------------
  ------------------
 1070|      4|		    ctos ? "client->server" : "server->client",
 1071|      4|		    newkeys->enc.name,
 1072|      4|		    authlen == 0 ? newkeys->mac.name : "<implicit>",
 1073|      4|		    newkeys->comp.name);
 1074|      4|	}
 1075|      2|	need = dh_need = 0;
 1076|      6|	for (mode = 0; mode < MODE_MAX; mode++) {
  ------------------
  |  Branch (1076:17): [True: 4, False: 2]
  ------------------
 1077|      4|		newkeys = kex->newkeys[mode];
 1078|      4|		need = MAXIMUM(need, newkeys->enc.key_len);
  ------------------
  |  |  269|      4|#define MAXIMUM(a, b)	(((a) > (b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (269:24): [True: 2, False: 2]
  |  |  ------------------
  ------------------
 1079|      4|		need = MAXIMUM(need, newkeys->enc.block_size);
  ------------------
  |  |  269|      4|#define MAXIMUM(a, b)	(((a) > (b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (269:24): [True: 2, False: 2]
  |  |  ------------------
  ------------------
 1080|      4|		need = MAXIMUM(need, newkeys->enc.iv_len);
  ------------------
  |  |  269|      4|#define MAXIMUM(a, b)	(((a) > (b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (269:24): [True: 2, False: 2]
  |  |  ------------------
  ------------------
 1081|      4|		need = MAXIMUM(need, newkeys->mac.key_len);
  ------------------
  |  |  269|      4|#define MAXIMUM(a, b)	(((a) > (b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (269:24): [True: 0, False: 4]
  |  |  ------------------
  ------------------
 1082|      4|		dh_need = MAXIMUM(dh_need, cipher_seclen(newkeys->enc.cipher));
  ------------------
  |  |  269|      4|#define MAXIMUM(a, b)	(((a) > (b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (269:24): [True: 2, False: 2]
  |  |  ------------------
  ------------------
 1083|      4|		dh_need = MAXIMUM(dh_need, newkeys->enc.block_size);
  ------------------
  |  |  269|      4|#define MAXIMUM(a, b)	(((a) > (b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (269:24): [True: 2, False: 2]
  |  |  ------------------
  ------------------
 1084|      4|		dh_need = MAXIMUM(dh_need, newkeys->enc.iv_len);
  ------------------
  |  |  269|      4|#define MAXIMUM(a, b)	(((a) > (b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (269:24): [True: 2, False: 2]
  |  |  ------------------
  ------------------
 1085|      4|		dh_need = MAXIMUM(dh_need, newkeys->mac.key_len);
  ------------------
  |  |  269|      4|#define MAXIMUM(a, b)	(((a) > (b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (269:24): [True: 0, False: 4]
  |  |  ------------------
  ------------------
 1086|      4|	}
 1087|       |	/* XXX need runden? */
 1088|      2|	kex->we_need = need;
 1089|      2|	kex->dh_need = dh_need;
 1090|       |
 1091|       |	/* ignore the next message if the proposals do not match */
 1092|      2|	if (first_kex_follows && !proposals_match(my, peer))
  ------------------
  |  Branch (1092:6): [True: 0, False: 2]
  |  Branch (1092:27): [True: 0, False: 0]
  ------------------
 1093|      0|		ssh->dispatch_skip_packets = 1;
 1094|      2|	r = 0;
 1095|      2| out:
 1096|      2|	kex_prop_free(my);
 1097|      2|	kex_prop_free(peer);
 1098|      2|	return r;
 1099|      2|}
kex.c:kexalgs_contains:
  964|      4|{
  965|      4|	return kex_has_any_alg(peer[PROPOSAL_KEX_ALGS], ext);
  966|      4|}
kex.c:choose_kex:
  903|      2|{
  904|      2|	k->name = match_list(client, server, NULL);
  905|       |
  906|      2|	debug("kex: algorithm: %s", k->name ? k->name : "(no match)");
  ------------------
  |  |  111|      4|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (111:88): [True: 2, False: 0]
  |  |  ------------------
  ------------------
  907|      2|	if (k->name == NULL)
  ------------------
  |  Branch (907:6): [True: 0, False: 2]
  ------------------
  908|      0|		return SSH_ERR_NO_KEX_ALG_MATCH;
  ------------------
  |  |   58|      0|#define SSH_ERR_NO_KEX_ALG_MATCH		-34
  ------------------
  909|      2|	if (!kex_name_valid(k->name)) {
  ------------------
  |  Branch (909:6): [True: 0, False: 2]
  ------------------
  910|      0|		error_f("unsupported KEX method %s", k->name);
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  911|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  912|      0|	}
  913|      2|	k->kex_type = kex_type_from_name(k->name);
  914|      2|	k->hash_alg = kex_hash_from_name(k->name);
  915|      2|	k->ec_nid = kex_nid_from_name(k->name);
  916|      2|	return 0;
  917|      2|}
kex.c:choose_hostkeyalg:
  921|      2|{
  922|      2|	free(k->hostkey_alg);
  923|      2|	k->hostkey_alg = match_list(client, server, NULL);
  924|       |
  925|      2|	debug("kex: host key algorithm: %s",
  ------------------
  |  |  111|      4|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (111:88): [True: 2, False: 0]
  |  |  ------------------
  ------------------
  926|      2|	    k->hostkey_alg ? k->hostkey_alg : "(no match)");
  927|      2|	if (k->hostkey_alg == NULL)
  ------------------
  |  Branch (927:6): [True: 0, False: 2]
  ------------------
  928|      0|		return SSH_ERR_NO_HOSTKEY_ALG_MATCH;
  ------------------
  |  |   59|      0|#define SSH_ERR_NO_HOSTKEY_ALG_MATCH		-35
  ------------------
  929|      2|	k->hostkey_type = sshkey_type_from_name(k->hostkey_alg);
  930|      2|	if (k->hostkey_type == KEY_UNSPEC) {
  ------------------
  |  Branch (930:6): [True: 0, False: 2]
  ------------------
  931|      0|		error_f("unsupported hostkey algorithm %s", k->hostkey_alg);
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  932|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  933|      0|	}
  934|      2|	k->hostkey_nid = sshkey_ecdsa_nid_from_name(k->hostkey_alg);
  935|      2|	return 0;
  936|      2|}
kex.c:choose_enc:
  840|      4|{
  841|      4|	char *name = match_list(client, server, NULL);
  842|       |
  843|      4|	if (name == NULL)
  ------------------
  |  Branch (843:6): [True: 0, False: 4]
  ------------------
  844|      0|		return SSH_ERR_NO_CIPHER_ALG_MATCH;
  ------------------
  |  |   55|      0|#define SSH_ERR_NO_CIPHER_ALG_MATCH		-31
  ------------------
  845|      4|	if ((enc->cipher = cipher_by_name(name)) == NULL) {
  ------------------
  |  Branch (845:6): [True: 0, False: 4]
  ------------------
  846|      0|		error_f("unsupported cipher %s", name);
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  847|      0|		free(name);
  848|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  849|      0|	}
  850|      4|	enc->name = name;
  851|      4|	enc->enabled = 0;
  852|      4|	enc->iv = NULL;
  853|      4|	enc->iv_len = cipher_ivlen(enc->cipher);
  854|       |	enc->key = NULL;
  855|      4|	enc->key_len = cipher_keylen(enc->cipher);
  856|      4|	enc->block_size = cipher_blocksize(enc->cipher);
  857|      4|	return 0;
  858|      4|}
kex.c:choose_mac:
  862|      4|{
  863|      4|	char *name = match_list(client, server, NULL);
  864|       |
  865|      4|	if (name == NULL)
  ------------------
  |  Branch (865:6): [True: 0, False: 4]
  ------------------
  866|      0|		return SSH_ERR_NO_MAC_ALG_MATCH;
  ------------------
  |  |   56|      0|#define SSH_ERR_NO_MAC_ALG_MATCH		-32
  ------------------
  867|      4|	if (mac_setup(mac, name) < 0) {
  ------------------
  |  Branch (867:6): [True: 0, False: 4]
  ------------------
  868|      0|		error_f("unsupported MAC %s", name);
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  869|      0|		free(name);
  870|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  871|      0|	}
  872|      4|	mac->name = name;
  873|       |	mac->key = NULL;
  874|      4|	mac->enabled = 0;
  875|      4|	return 0;
  876|      4|}
kex.c:choose_comp:
  880|      4|{
  881|      4|	char *name = match_list(client, server, NULL);
  882|       |
  883|      4|	if (name == NULL)
  ------------------
  |  Branch (883:6): [True: 0, False: 4]
  ------------------
  884|      0|		return SSH_ERR_NO_COMPRESS_ALG_MATCH;
  ------------------
  |  |   57|      0|#define SSH_ERR_NO_COMPRESS_ALG_MATCH		-33
  ------------------
  885|      4|#ifdef WITH_ZLIB
  886|      4|	if (strcmp(name, "zlib@openssh.com") == 0) {
  ------------------
  |  Branch (886:6): [True: 0, False: 4]
  ------------------
  887|      0|		comp->type = COMP_DELAYED;
  ------------------
  |  |   64|      0|#define COMP_DELAYED	2
  ------------------
  888|      0|	} else
  889|      4|#endif	/* WITH_ZLIB */
  890|      4|	if (strcmp(name, "none") == 0) {
  ------------------
  |  Branch (890:6): [True: 4, False: 0]
  ------------------
  891|      4|		comp->type = COMP_NONE;
  ------------------
  |  |   63|      4|#define COMP_NONE	0
  ------------------
  892|      4|	} else {
  893|      0|		error_f("unsupported compression scheme %s", name);
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  894|      0|		free(name);
  895|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  896|      0|	}
  897|      4|	comp->name = name;
  898|      4|	return 0;
  899|      4|}
kex.c:derive_key:
 1104|     12|{
 1105|     12|	struct kex *kex = ssh->kex;
 1106|     12|	struct ssh_digest_ctx *hashctx = NULL;
 1107|     12|	char c = id;
 1108|     12|	u_int have;
 1109|     12|	size_t mdsz;
 1110|     12|	u_char *digest;
 1111|     12|	int r;
 1112|       |
 1113|     12|	if ((mdsz = ssh_digest_bytes(kex->hash_alg)) == 0)
  ------------------
  |  Branch (1113:6): [True: 0, False: 12]
  ------------------
 1114|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
 1115|     12|	if ((digest = calloc(1, ROUNDUP(need, mdsz))) == NULL) {
  ------------------
  |  |  270|     12|#define ROUNDUP(x, y)   ((((x)+((y)-1))/(y))*(y))
  ------------------
  |  Branch (1115:6): [True: 0, False: 12]
  ------------------
 1116|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 1117|      0|		goto out;
 1118|      0|	}
 1119|       |
 1120|       |	/* K1 = HASH(K || H || "A" || session_id) */
 1121|     12|	if ((hashctx = ssh_digest_start(kex->hash_alg)) == NULL ||
  ------------------
  |  Branch (1121:6): [True: 0, False: 12]
  ------------------
 1122|     12|	    ssh_digest_update_buffer(hashctx, shared_secret) != 0 ||
  ------------------
  |  Branch (1122:6): [True: 0, False: 12]
  ------------------
 1123|     12|	    ssh_digest_update(hashctx, hash, hashlen) != 0 ||
  ------------------
  |  Branch (1123:6): [True: 0, False: 12]
  ------------------
 1124|     12|	    ssh_digest_update(hashctx, &c, 1) != 0 ||
  ------------------
  |  Branch (1124:6): [True: 0, False: 12]
  ------------------
 1125|     12|	    ssh_digest_update_buffer(hashctx, kex->session_id) != 0 ||
  ------------------
  |  Branch (1125:6): [True: 0, False: 12]
  ------------------
 1126|     12|	    ssh_digest_final(hashctx, digest, mdsz) != 0) {
  ------------------
  |  Branch (1126:6): [True: 0, False: 12]
  ------------------
 1127|      0|		r = SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
 1128|      0|		error_f("KEX hash failed");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
 1129|      0|		goto out;
 1130|      0|	}
 1131|     12|	ssh_digest_free(hashctx);
 1132|     12|	hashctx = NULL;
 1133|       |
 1134|       |	/*
 1135|       |	 * expand key:
 1136|       |	 * Kn = HASH(K || H || K1 || K2 || ... || Kn-1)
 1137|       |	 * Key = K1 || K2 || ... || Kn
 1138|       |	 */
 1139|     12|	for (have = mdsz; need > have; have += mdsz) {
  ------------------
  |  Branch (1139:20): [True: 0, False: 12]
  ------------------
 1140|      0|		if ((hashctx = ssh_digest_start(kex->hash_alg)) == NULL ||
  ------------------
  |  Branch (1140:7): [True: 0, False: 0]
  ------------------
 1141|      0|		    ssh_digest_update_buffer(hashctx, shared_secret) != 0 ||
  ------------------
  |  Branch (1141:7): [True: 0, False: 0]
  ------------------
 1142|      0|		    ssh_digest_update(hashctx, hash, hashlen) != 0 ||
  ------------------
  |  Branch (1142:7): [True: 0, False: 0]
  ------------------
 1143|      0|		    ssh_digest_update(hashctx, digest, have) != 0 ||
  ------------------
  |  Branch (1143:7): [True: 0, False: 0]
  ------------------
 1144|      0|		    ssh_digest_final(hashctx, digest + have, mdsz) != 0) {
  ------------------
  |  Branch (1144:7): [True: 0, False: 0]
  ------------------
 1145|      0|			error_f("KDF failed");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
 1146|      0|			r = SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
 1147|      0|			goto out;
 1148|      0|		}
 1149|      0|		ssh_digest_free(hashctx);
 1150|      0|		hashctx = NULL;
 1151|      0|	}
 1152|       |#ifdef DEBUG_KEX
 1153|       |	fprintf(stderr, "key '%c'== ", c);
 1154|       |	dump_digest("key", digest, need);
 1155|       |#endif
 1156|     12|	*keyp = digest;
 1157|     12|	digest = NULL;
 1158|     12|	r = 0;
 1159|     12| out:
 1160|     12|	free(digest);
 1161|     12|	ssh_digest_free(hashctx);
 1162|     12|	return r;
 1163|     12|}

kexc25519_keygen:
   51|      2|{
   52|      2|	static const u_char basepoint[CURVE25519_SIZE] = {9};
   53|       |
   54|      2|	arc4random_buf(key, CURVE25519_SIZE);
  ------------------
  |  |   66|      2|#define CURVE25519_SIZE 32
  ------------------
   55|      2|	crypto_scalarmult_curve25519(pub, key, basepoint);
   56|      2|}
kexc25519_shared_key_ext:
   61|      2|{
   62|      2|	u_char shared_key[CURVE25519_SIZE];
   63|      2|	u_char zero[CURVE25519_SIZE];
   64|      2|	int r;
   65|       |
   66|      2|	crypto_scalarmult_curve25519(shared_key, key, pub);
   67|       |
   68|       |	/* Check for all-zero shared secret */
   69|      2|	explicit_bzero(zero, CURVE25519_SIZE);
  ------------------
  |  |   66|      2|#define CURVE25519_SIZE 32
  ------------------
   70|      2|	if (timingsafe_bcmp(zero, shared_key, CURVE25519_SIZE) == 0)
  ------------------
  |  |   66|      2|#define CURVE25519_SIZE 32
  ------------------
  |  Branch (70:6): [True: 0, False: 2]
  ------------------
   71|      0|		return SSH_ERR_KEY_INVALID_EC_VALUE;
  ------------------
  |  |   44|      0|#define SSH_ERR_KEY_INVALID_EC_VALUE		-20
  ------------------
   72|       |
   73|       |#ifdef DEBUG_KEXECDH
   74|       |	dump_digest("shared secret 25519", shared_key, CURVE25519_SIZE);
   75|       |#endif
   76|      2|	if (raw)
  ------------------
  |  Branch (76:6): [True: 0, False: 2]
  ------------------
   77|      0|		r = sshbuf_put(out, shared_key, CURVE25519_SIZE);
  ------------------
  |  |   66|      0|#define CURVE25519_SIZE 32
  ------------------
   78|      2|	else
   79|      2|		r = sshbuf_put_bignum2_bytes(out, shared_key, CURVE25519_SIZE);
  ------------------
  |  |   66|      2|#define CURVE25519_SIZE 32
  ------------------
   80|      2|	explicit_bzero(shared_key, CURVE25519_SIZE);
  ------------------
  |  |   66|      2|#define CURVE25519_SIZE 32
  ------------------
   81|      2|	return r;
   82|      2|}
kex_c25519_keypair:
   93|      1|{
   94|      1|	struct sshbuf *buf = NULL;
   95|      1|	u_char *cp = NULL;
   96|      1|	int r;
   97|       |
   98|      1|	if ((buf = sshbuf_new()) == NULL)
  ------------------
  |  Branch (98:6): [True: 0, False: 1]
  ------------------
   99|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  100|      1|	if ((r = sshbuf_reserve(buf, CURVE25519_SIZE, &cp)) != 0)
  ------------------
  |  |   66|      1|#define CURVE25519_SIZE 32
  ------------------
  |  Branch (100:6): [True: 0, False: 1]
  ------------------
  101|      0|		goto out;
  102|      1|	kexc25519_keygen(kex->c25519_client_key, cp);
  103|       |#ifdef DEBUG_KEXECDH
  104|       |	dump_digest("client public key c25519:", cp, CURVE25519_SIZE);
  105|       |#endif
  106|      1|	kex->client_pub = buf;
  107|      1|	buf = NULL;
  108|      1| out:
  109|      1|	sshbuf_free(buf);
  110|      1|	return r;
  111|      1|}
kex_c25519_enc:
  116|      1|{
  117|      1|	struct sshbuf *server_blob = NULL;
  118|      1|	struct sshbuf *buf = NULL;
  119|      1|	const u_char *client_pub;
  120|      1|	u_char *server_pub;
  121|      1|	u_char server_key[CURVE25519_SIZE];
  122|      1|	int r;
  123|       |
  124|      1|	*server_blobp = NULL;
  125|      1|	*shared_secretp = NULL;
  126|       |
  127|      1|	if (sshbuf_len(client_blob) != CURVE25519_SIZE) {
  ------------------
  |  |   66|      1|#define CURVE25519_SIZE 32
  ------------------
  |  Branch (127:6): [True: 0, False: 1]
  ------------------
  128|      0|		r = SSH_ERR_SIGNATURE_INVALID;
  ------------------
  |  |   45|      0|#define SSH_ERR_SIGNATURE_INVALID		-21
  ------------------
  129|      0|		goto out;
  130|      0|	}
  131|      1|	client_pub = sshbuf_ptr(client_blob);
  132|       |#ifdef DEBUG_KEXECDH
  133|       |	dump_digest("client public key 25519:", client_pub, CURVE25519_SIZE);
  134|       |#endif
  135|       |	/* allocate space for encrypted KEM key and ECDH pub key */
  136|      1|	if ((server_blob = sshbuf_new()) == NULL) {
  ------------------
  |  Branch (136:6): [True: 0, False: 1]
  ------------------
  137|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  138|      0|		goto out;
  139|      0|	}
  140|      1|	if ((r = sshbuf_reserve(server_blob, CURVE25519_SIZE, &server_pub)) != 0)
  ------------------
  |  |   66|      1|#define CURVE25519_SIZE 32
  ------------------
  |  Branch (140:6): [True: 0, False: 1]
  ------------------
  141|      0|		goto out;
  142|      1|	kexc25519_keygen(server_key, server_pub);
  143|       |	/* allocate shared secret */
  144|      1|	if ((buf = sshbuf_new()) == NULL) {
  ------------------
  |  Branch (144:6): [True: 0, False: 1]
  ------------------
  145|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  146|      0|		goto out;
  147|      0|	}
  148|      1|	if ((r = kexc25519_shared_key_ext(server_key, client_pub, buf, 0)) < 0)
  ------------------
  |  Branch (148:6): [True: 0, False: 1]
  ------------------
  149|      0|		goto out;
  150|       |#ifdef DEBUG_KEXECDH
  151|       |	dump_digest("server public key 25519:", server_pub, CURVE25519_SIZE);
  152|       |	dump_digest("encoded shared secret:", sshbuf_ptr(buf), sshbuf_len(buf));
  153|       |#endif
  154|      1|	*server_blobp = server_blob;
  155|      1|	*shared_secretp = buf;
  156|      1|	server_blob = NULL;
  157|      1|	buf = NULL;
  158|      1| out:
  159|      1|	explicit_bzero(server_key, sizeof(server_key));
  160|      1|	sshbuf_free(server_blob);
  161|      1|	sshbuf_free(buf);
  162|      1|	return r;
  163|      1|}
kex_c25519_dec:
  168|      1|{
  169|      1|	struct sshbuf *buf = NULL;
  170|      1|	const u_char *server_pub;
  171|      1|	int r;
  172|       |
  173|      1|	*shared_secretp = NULL;
  174|       |
  175|      1|	if (sshbuf_len(server_blob) != CURVE25519_SIZE) {
  ------------------
  |  |   66|      1|#define CURVE25519_SIZE 32
  ------------------
  |  Branch (175:6): [True: 0, False: 1]
  ------------------
  176|      0|		r = SSH_ERR_SIGNATURE_INVALID;
  ------------------
  |  |   45|      0|#define SSH_ERR_SIGNATURE_INVALID		-21
  ------------------
  177|      0|		goto out;
  178|      0|	}
  179|      1|	server_pub = sshbuf_ptr(server_blob);
  180|       |#ifdef DEBUG_KEXECDH
  181|       |	dump_digest("server public key c25519:", server_pub, CURVE25519_SIZE);
  182|       |#endif
  183|       |	/* shared secret */
  184|      1|	if ((buf = sshbuf_new()) == NULL) {
  ------------------
  |  Branch (184:6): [True: 0, False: 1]
  ------------------
  185|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  186|      0|		goto out;
  187|      0|	}
  188|      1|	if ((r = kexc25519_shared_key_ext(kex->c25519_client_key, server_pub,
  ------------------
  |  Branch (188:6): [True: 0, False: 1]
  ------------------
  189|      1|	    buf, 0)) < 0)
  190|      0|		goto out;
  191|       |#ifdef DEBUG_KEXECDH
  192|       |	dump_digest("encoded shared secret:", sshbuf_ptr(buf), sshbuf_len(buf));
  193|       |#endif
  194|      1|	*shared_secretp = buf;
  195|      1|	buf = NULL;
  196|      1| out:
  197|      1|	sshbuf_free(buf);
  198|      1|	return r;
  199|      1|}

kex_gen_client:
  100|      1|{
  101|      1|	struct kex *kex = ssh->kex;
  102|      1|	int r;
  103|       |
  104|      1|	switch (kex->kex_type) {
  105|      0|#ifdef WITH_OPENSSL
  106|      0|	case KEX_DH_GRP1_SHA1:
  ------------------
  |  Branch (106:2): [True: 0, False: 1]
  ------------------
  107|      0|	case KEX_DH_GRP14_SHA1:
  ------------------
  |  Branch (107:2): [True: 0, False: 1]
  ------------------
  108|      0|	case KEX_DH_GRP14_SHA256:
  ------------------
  |  Branch (108:2): [True: 0, False: 1]
  ------------------
  109|      0|	case KEX_DH_GRP16_SHA512:
  ------------------
  |  Branch (109:2): [True: 0, False: 1]
  ------------------
  110|      0|	case KEX_DH_GRP18_SHA512:
  ------------------
  |  Branch (110:2): [True: 0, False: 1]
  ------------------
  111|      0|		r = kex_dh_keypair(kex);
  112|      0|		break;
  113|      0|	case KEX_ECDH_SHA2:
  ------------------
  |  Branch (113:2): [True: 0, False: 1]
  ------------------
  114|      0|		r = kex_ecdh_keypair(kex);
  115|      0|		break;
  116|      0|	case KEX_KEM_MLKEM768ECDH_SHA256:
  ------------------
  |  Branch (116:2): [True: 0, False: 1]
  ------------------
  117|      0|		r = kex_kem_mlkem768ecdh_keypair(kex);
  118|      0|		break;
  119|      0|#endif /* WITH_OPENSSL */
  120|      1|	case KEX_C25519_SHA256:
  ------------------
  |  Branch (120:2): [True: 1, False: 0]
  ------------------
  121|      1|		r = kex_c25519_keypair(kex);
  122|      1|		break;
  123|      0|	case KEX_KEM_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (123:2): [True: 0, False: 1]
  ------------------
  124|      0|		r = kex_kem_sntrup761x25519_keypair(kex);
  125|      0|		break;
  126|      0|	case KEX_KEM_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (126:2): [True: 0, False: 1]
  ------------------
  127|      0|		r = kex_kem_mlkem768x25519_keypair(kex);
  128|      0|		break;
  129|      0|	default:
  ------------------
  |  Branch (129:2): [True: 0, False: 1]
  ------------------
  130|      0|		r = SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  131|      0|		break;
  132|      1|	}
  133|      1|	if (r != 0)
  ------------------
  |  Branch (133:6): [True: 0, False: 1]
  ------------------
  134|      0|		return r;
  135|      1|	if ((r = sshpkt_start(ssh, SSH2_MSG_KEX_ECDH_INIT)) != 0 ||
  ------------------
  |  |  109|      1|#define SSH2_MSG_KEX_ECDH_INIT				30
  ------------------
  |  Branch (135:6): [True: 0, False: 1]
  ------------------
  136|      1|	    (r = sshpkt_put_stringb(ssh, kex->client_pub)) != 0 ||
  ------------------
  |  Branch (136:6): [True: 0, False: 1]
  ------------------
  137|      1|	    (r = sshpkt_send(ssh)) != 0)
  ------------------
  |  Branch (137:6): [True: 0, False: 1]
  ------------------
  138|      0|		return r;
  139|      1|	debug("expecting SSH2_MSG_KEX_ECDH_REPLY");
  ------------------
  |  |  111|      1|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  140|      1|	ssh_dispatch_set(ssh, SSH2_MSG_KEX_ECDH_REPLY, &input_kex_gen_reply);
  ------------------
  |  |  110|      1|#define SSH2_MSG_KEX_ECDH_REPLY				31
  ------------------
  141|      1|	return 0;
  142|      1|}
kex_gen_server:
  276|      1|{
  277|      1|	debug("expecting SSH2_MSG_KEX_ECDH_INIT");
  ------------------
  |  |  111|      1|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  278|      1|	ssh_dispatch_set(ssh, SSH2_MSG_KEX_ECDH_INIT, &input_kex_gen_init);
  ------------------
  |  |  109|      1|#define SSH2_MSG_KEX_ECDH_INIT				30
  ------------------
  279|      1|	return 0;
  280|      1|}
kexgen.c:input_kex_gen_reply:
  146|      1|{
  147|      1|	struct kex *kex = ssh->kex;
  148|      1|	struct sshkey *server_host_key = NULL;
  149|      1|	struct sshbuf *shared_secret = NULL;
  150|      1|	struct sshbuf *server_blob = NULL;
  151|      1|	struct sshbuf *tmp = NULL, *server_host_key_blob = NULL;
  152|      1|	u_char *signature = NULL;
  153|      1|	u_char hash[SSH_DIGEST_MAX_LENGTH];
  154|      1|	size_t slen, hashlen;
  155|      1|	int r;
  156|       |
  157|      1|	debug("SSH2_MSG_KEX_ECDH_REPLY received");
  ------------------
  |  |  111|      1|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  158|      1|	ssh_dispatch_set(ssh, SSH2_MSG_KEX_ECDH_REPLY, &kex_protocol_error);
  ------------------
  |  |  110|      1|#define SSH2_MSG_KEX_ECDH_REPLY				31
  ------------------
  159|       |
  160|       |	/* hostkey */
  161|      1|	if ((r = sshpkt_getb_froms(ssh, &server_host_key_blob)) != 0)
  ------------------
  |  Branch (161:6): [True: 0, False: 1]
  ------------------
  162|      0|		goto out;
  163|       |	/* sshkey_fromb() consumes its buffer, so make a copy */
  164|      1|	if ((tmp = sshbuf_fromb(server_host_key_blob)) == NULL) {
  ------------------
  |  Branch (164:6): [True: 0, False: 1]
  ------------------
  165|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  166|      0|		goto out;
  167|      0|	}
  168|      1|	if ((r = sshkey_fromb_allowlist(tmp, &server_host_key,
  ------------------
  |  Branch (168:6): [True: 0, False: 1]
  ------------------
  169|      1|	    kex->hostkey_alg, NULL)) != 0)
  170|      0|		goto out;
  171|      1|	if ((r = kex_verify_host_key(ssh, server_host_key)) != 0)
  ------------------
  |  Branch (171:6): [True: 0, False: 1]
  ------------------
  172|      0|		goto out;
  173|       |
  174|       |	/* Q_S, server public key */
  175|       |	/* signed H */
  176|      1|	if ((r = sshpkt_getb_froms(ssh, &server_blob)) != 0 ||
  ------------------
  |  Branch (176:6): [True: 0, False: 1]
  ------------------
  177|      1|	    (r = sshpkt_get_string(ssh, &signature, &slen)) != 0 ||
  ------------------
  |  Branch (177:6): [True: 0, False: 1]
  ------------------
  178|      1|	    (r = sshpkt_get_end(ssh)) != 0)
  ------------------
  |  Branch (178:6): [True: 0, False: 1]
  ------------------
  179|      0|		goto out;
  180|       |
  181|       |	/* compute shared secret */
  182|      1|	switch (kex->kex_type) {
  183|      0|#ifdef WITH_OPENSSL
  184|      0|	case KEX_DH_GRP1_SHA1:
  ------------------
  |  Branch (184:2): [True: 0, False: 1]
  ------------------
  185|      0|	case KEX_DH_GRP14_SHA1:
  ------------------
  |  Branch (185:2): [True: 0, False: 1]
  ------------------
  186|      0|	case KEX_DH_GRP14_SHA256:
  ------------------
  |  Branch (186:2): [True: 0, False: 1]
  ------------------
  187|      0|	case KEX_DH_GRP16_SHA512:
  ------------------
  |  Branch (187:2): [True: 0, False: 1]
  ------------------
  188|      0|	case KEX_DH_GRP18_SHA512:
  ------------------
  |  Branch (188:2): [True: 0, False: 1]
  ------------------
  189|      0|		r = kex_dh_dec(kex, server_blob, &shared_secret);
  190|      0|		break;
  191|      0|	case KEX_ECDH_SHA2:
  ------------------
  |  Branch (191:2): [True: 0, False: 1]
  ------------------
  192|      0|		r = kex_ecdh_dec(kex, server_blob, &shared_secret);
  193|      0|		break;
  194|      0|	case KEX_KEM_MLKEM768ECDH_SHA256:
  ------------------
  |  Branch (194:2): [True: 0, False: 1]
  ------------------
  195|      0|		r = kex_kem_mlkem768ecdh_dec(kex, server_blob,
  196|      0|		    &shared_secret);
  197|      0|		break;
  198|      0|#endif /* WITH_OPENSSL */
  199|      1|	case KEX_C25519_SHA256:
  ------------------
  |  Branch (199:2): [True: 1, False: 0]
  ------------------
  200|      1|		r = kex_c25519_dec(kex, server_blob, &shared_secret);
  201|      1|		break;
  202|      0|	case KEX_KEM_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (202:2): [True: 0, False: 1]
  ------------------
  203|      0|		r = kex_kem_sntrup761x25519_dec(kex, server_blob,
  204|      0|		    &shared_secret);
  205|      0|		break;
  206|      0|	case KEX_KEM_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (206:2): [True: 0, False: 1]
  ------------------
  207|      0|		r = kex_kem_mlkem768x25519_dec(kex, server_blob,
  208|      0|		    &shared_secret);
  209|      0|		break;
  210|      0|	default:
  ------------------
  |  Branch (210:2): [True: 0, False: 1]
  ------------------
  211|      0|		r = SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  212|      0|		break;
  213|      1|	}
  214|      1|	if (r !=0 )
  ------------------
  |  Branch (214:6): [True: 0, False: 1]
  ------------------
  215|      0|		goto out;
  216|       |
  217|       |	/* calc and verify H */
  218|      1|	hashlen = sizeof(hash);
  219|      1|	if ((r = kex_gen_hash(
  ------------------
  |  Branch (219:6): [True: 0, False: 1]
  ------------------
  220|      1|	    kex->hash_alg,
  221|      1|	    kex->client_version,
  222|      1|	    kex->server_version,
  223|      1|	    kex->my,
  224|      1|	    kex->peer,
  225|      1|	    server_host_key_blob,
  226|      1|	    kex->client_pub,
  227|      1|	    server_blob,
  228|      1|	    shared_secret,
  229|      1|	    hash, &hashlen)) != 0)
  230|      0|		goto out;
  231|       |
  232|      1|	if ((r = sshkey_verify(server_host_key, signature, slen, hash, hashlen,
  ------------------
  |  Branch (232:6): [True: 0, False: 1]
  ------------------
  233|      1|	    kex->hostkey_alg, ssh->compat, NULL)) != 0)
  234|      0|		goto out;
  235|       |
  236|      1|	if ((r = kex_derive_keys(ssh, hash, hashlen, shared_secret)) != 0 ||
  ------------------
  |  Branch (236:6): [True: 0, False: 1]
  ------------------
  237|      1|	    (r = kex_send_newkeys(ssh)) != 0)
  ------------------
  |  Branch (237:6): [True: 0, False: 1]
  ------------------
  238|      0|		goto out;
  239|       |
  240|       |	/* save initial signature and hostkey */
  241|      1|	if ((kex->flags & KEX_INITIAL) != 0) {
  ------------------
  |  |  106|      1|#define KEX_INITIAL			0x0002
  ------------------
  |  Branch (241:6): [True: 1, False: 0]
  ------------------
  242|      1|		if (kex->initial_hostkey != NULL || kex->initial_sig != NULL) {
  ------------------
  |  Branch (242:7): [True: 0, False: 1]
  |  Branch (242:39): [True: 0, False: 1]
  ------------------
  243|      0|			r = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  244|      0|			goto out;
  245|      0|		}
  246|      1|		if ((kex->initial_sig = sshbuf_new()) == NULL) {
  ------------------
  |  Branch (246:7): [True: 0, False: 1]
  ------------------
  247|      0|			r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  248|      0|			goto out;
  249|      0|		}
  250|      1|		if ((r = sshbuf_put(kex->initial_sig, signature, slen)) != 0)
  ------------------
  |  Branch (250:7): [True: 0, False: 1]
  ------------------
  251|      0|			goto out;
  252|      1|		kex->initial_hostkey = server_host_key;
  253|      1|		server_host_key = NULL;
  254|      1|	}
  255|       |	/* success */
  256|      1|out:
  257|      1|	explicit_bzero(hash, sizeof(hash));
  258|      1|	explicit_bzero(kex->c25519_client_key, sizeof(kex->c25519_client_key));
  259|      1|	explicit_bzero(kex->sntrup761_client_key,
  260|      1|	    sizeof(kex->sntrup761_client_key));
  261|      1|	explicit_bzero(kex->mlkem768_client_key,
  262|      1|	    sizeof(kex->mlkem768_client_key));
  263|      1|	sshbuf_free(server_host_key_blob);
  264|      1|	free(signature);
  265|      1|	sshbuf_free(tmp);
  266|      1|	sshkey_free(server_host_key);
  267|      1|	sshbuf_free(server_blob);
  268|      1|	sshbuf_free(shared_secret);
  269|      1|	sshbuf_free(kex->client_pub);
  270|       |	kex->client_pub = NULL;
  271|      1|	return r;
  272|      1|}
kexgen.c:kex_gen_hash:
   59|      2|{
   60|      2|	struct sshbuf *b;
   61|      2|	int r;
   62|       |
   63|      2|	if (*hashlen < ssh_digest_bytes(hash_alg))
  ------------------
  |  Branch (63:6): [True: 0, False: 2]
  ------------------
   64|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
   65|      2|	if ((b = sshbuf_new()) == NULL)
  ------------------
  |  Branch (65:6): [True: 0, False: 2]
  ------------------
   66|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
   67|      2|	if ((r = sshbuf_put_stringb(b, client_version)) != 0 ||
  ------------------
  |  Branch (67:6): [True: 0, False: 2]
  ------------------
   68|      2|	    (r = sshbuf_put_stringb(b, server_version)) != 0 ||
  ------------------
  |  Branch (68:6): [True: 0, False: 2]
  ------------------
   69|       |	    /* kexinit messages: fake header: len+SSH2_MSG_KEXINIT */
   70|      2|	    (r = sshbuf_put_u32(b, sshbuf_len(client_kexinit) + 1)) != 0 ||
  ------------------
  |  Branch (70:6): [True: 0, False: 2]
  ------------------
   71|      2|	    (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 ||
  ------------------
  |  |   93|      2|#define SSH2_MSG_KEXINIT				20
  ------------------
  |  Branch (71:6): [True: 0, False: 2]
  ------------------
   72|      2|	    (r = sshbuf_putb(b, client_kexinit)) != 0 ||
  ------------------
  |  Branch (72:6): [True: 0, False: 2]
  ------------------
   73|      2|	    (r = sshbuf_put_u32(b, sshbuf_len(server_kexinit) + 1)) != 0 ||
  ------------------
  |  Branch (73:6): [True: 0, False: 2]
  ------------------
   74|      2|	    (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 ||
  ------------------
  |  |   93|      2|#define SSH2_MSG_KEXINIT				20
  ------------------
  |  Branch (74:6): [True: 0, False: 2]
  ------------------
   75|      2|	    (r = sshbuf_putb(b, server_kexinit)) != 0 ||
  ------------------
  |  Branch (75:6): [True: 0, False: 2]
  ------------------
   76|      2|	    (r = sshbuf_put_stringb(b, server_host_key_blob)) != 0 ||
  ------------------
  |  Branch (76:6): [True: 0, False: 2]
  ------------------
   77|      2|	    (r = sshbuf_put_stringb(b, client_pub)) != 0 ||
  ------------------
  |  Branch (77:6): [True: 0, False: 2]
  ------------------
   78|      2|	    (r = sshbuf_put_stringb(b, server_pub)) != 0 ||
  ------------------
  |  Branch (78:6): [True: 0, False: 2]
  ------------------
   79|      2|	    (r = sshbuf_putb(b, shared_secret)) != 0) {
  ------------------
  |  Branch (79:6): [True: 0, False: 2]
  ------------------
   80|      0|		sshbuf_free(b);
   81|      0|		return r;
   82|      0|	}
   83|       |#ifdef DEBUG_KEX
   84|       |	sshbuf_dump(b, stderr);
   85|       |#endif
   86|      2|	if (ssh_digest_buffer(hash_alg, b, hash, *hashlen) != 0) {
  ------------------
  |  Branch (86:6): [True: 0, False: 2]
  ------------------
   87|      0|		sshbuf_free(b);
   88|      0|		return SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
   89|      0|	}
   90|      2|	sshbuf_free(b);
   91|      2|	*hashlen = ssh_digest_bytes(hash_alg);
   92|       |#ifdef DEBUG_KEX
   93|       |	dump_digest("hash", hash, *hashlen);
   94|       |#endif
   95|      2|	return 0;
   96|      2|}
kexgen.c:input_kex_gen_init:
  284|      1|{
  285|      1|	struct kex *kex = ssh->kex;
  286|      1|	struct sshkey *server_host_private, *server_host_public;
  287|      1|	struct sshbuf *shared_secret = NULL;
  288|      1|	struct sshbuf *server_pubkey = NULL;
  289|      1|	struct sshbuf *client_pubkey = NULL;
  290|      1|	struct sshbuf *server_host_key_blob = NULL;
  291|      1|	u_char *signature = NULL, hash[SSH_DIGEST_MAX_LENGTH];
  292|      1|	size_t slen, hashlen;
  293|      1|	int r;
  294|       |
  295|      1|	debug("SSH2_MSG_KEX_ECDH_INIT received");
  ------------------
  |  |  111|      1|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  296|      1|	ssh_dispatch_set(ssh, SSH2_MSG_KEX_ECDH_INIT, &kex_protocol_error);
  ------------------
  |  |  109|      1|#define SSH2_MSG_KEX_ECDH_INIT				30
  ------------------
  297|       |
  298|      1|	if ((r = kex_load_hostkey(ssh, &server_host_private,
  ------------------
  |  Branch (298:6): [True: 0, False: 1]
  ------------------
  299|      1|	    &server_host_public)) != 0)
  300|      0|		goto out;
  301|       |
  302|      1|	if ((r = sshpkt_getb_froms(ssh, &client_pubkey)) != 0 ||
  ------------------
  |  Branch (302:6): [True: 0, False: 1]
  ------------------
  303|      1|	    (r = sshpkt_get_end(ssh)) != 0)
  ------------------
  |  Branch (303:6): [True: 0, False: 1]
  ------------------
  304|      0|		goto out;
  305|       |
  306|       |	/* compute shared secret */
  307|      1|	switch (kex->kex_type) {
  308|      0|#ifdef WITH_OPENSSL
  309|      0|	case KEX_DH_GRP1_SHA1:
  ------------------
  |  Branch (309:2): [True: 0, False: 1]
  ------------------
  310|      0|	case KEX_DH_GRP14_SHA1:
  ------------------
  |  Branch (310:2): [True: 0, False: 1]
  ------------------
  311|      0|	case KEX_DH_GRP14_SHA256:
  ------------------
  |  Branch (311:2): [True: 0, False: 1]
  ------------------
  312|      0|	case KEX_DH_GRP16_SHA512:
  ------------------
  |  Branch (312:2): [True: 0, False: 1]
  ------------------
  313|      0|	case KEX_DH_GRP18_SHA512:
  ------------------
  |  Branch (313:2): [True: 0, False: 1]
  ------------------
  314|      0|		r = kex_dh_enc(kex, client_pubkey, &server_pubkey,
  315|      0|		    &shared_secret);
  316|      0|		break;
  317|      0|	case KEX_ECDH_SHA2:
  ------------------
  |  Branch (317:2): [True: 0, False: 1]
  ------------------
  318|      0|		r = kex_ecdh_enc(kex, client_pubkey, &server_pubkey,
  319|      0|		    &shared_secret);
  320|      0|		break;
  321|      0|	case KEX_KEM_MLKEM768ECDH_SHA256:
  ------------------
  |  Branch (321:2): [True: 0, False: 1]
  ------------------
  322|      0|		r = kex_kem_mlkem768ecdh_enc(kex, client_pubkey,
  323|      0|		    &server_pubkey, &shared_secret);
  324|      0|		break;
  325|      0|#endif /* WITH_OPENSSL */
  326|      1|	case KEX_C25519_SHA256:
  ------------------
  |  Branch (326:2): [True: 1, False: 0]
  ------------------
  327|      1|		r = kex_c25519_enc(kex, client_pubkey, &server_pubkey,
  328|      1|		    &shared_secret);
  329|      1|		break;
  330|      0|	case KEX_KEM_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (330:2): [True: 0, False: 1]
  ------------------
  331|      0|		r = kex_kem_sntrup761x25519_enc(kex, client_pubkey,
  332|      0|		    &server_pubkey, &shared_secret);
  333|      0|		break;
  334|      0|	case KEX_KEM_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (334:2): [True: 0, False: 1]
  ------------------
  335|      0|		r = kex_kem_mlkem768x25519_enc(kex, client_pubkey,
  336|      0|		    &server_pubkey, &shared_secret);
  337|      0|		break;
  338|      0|	default:
  ------------------
  |  Branch (338:2): [True: 0, False: 1]
  ------------------
  339|      0|		r = SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  340|      0|		break;
  341|      1|	}
  342|      1|	if (r !=0 )
  ------------------
  |  Branch (342:6): [True: 0, False: 1]
  ------------------
  343|      0|		goto out;
  344|       |
  345|       |	/* calc H */
  346|      1|	if ((server_host_key_blob = sshbuf_new()) == NULL) {
  ------------------
  |  Branch (346:6): [True: 0, False: 1]
  ------------------
  347|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  348|      0|		goto out;
  349|      0|	}
  350|      1|	if ((r = sshkey_putb(server_host_public, server_host_key_blob)) != 0)
  ------------------
  |  Branch (350:6): [True: 0, False: 1]
  ------------------
  351|      0|		goto out;
  352|      1|	hashlen = sizeof(hash);
  353|      1|	if ((r = kex_gen_hash(
  ------------------
  |  Branch (353:6): [True: 0, False: 1]
  ------------------
  354|      1|	    kex->hash_alg,
  355|      1|	    kex->client_version,
  356|      1|	    kex->server_version,
  357|      1|	    kex->peer,
  358|      1|	    kex->my,
  359|      1|	    server_host_key_blob,
  360|      1|	    client_pubkey,
  361|      1|	    server_pubkey,
  362|      1|	    shared_secret,
  363|      1|	    hash, &hashlen)) != 0)
  364|      0|		goto out;
  365|       |
  366|       |	/* sign H */
  367|      1|	if ((r = kex->sign(ssh, server_host_private, server_host_public,
  ------------------
  |  Branch (367:6): [True: 0, False: 1]
  ------------------
  368|      1|	    &signature, &slen, hash, hashlen, kex->hostkey_alg)) != 0)
  369|      0|		goto out;
  370|       |
  371|       |	/* send server hostkey, ECDH pubkey 'Q_S' and signed H */
  372|      1|	if ((r = sshpkt_start(ssh, SSH2_MSG_KEX_ECDH_REPLY)) != 0 ||
  ------------------
  |  |  110|      1|#define SSH2_MSG_KEX_ECDH_REPLY				31
  ------------------
  |  Branch (372:6): [True: 0, False: 1]
  ------------------
  373|      1|	    (r = sshpkt_put_stringb(ssh, server_host_key_blob)) != 0 ||
  ------------------
  |  Branch (373:6): [True: 0, False: 1]
  ------------------
  374|      1|	    (r = sshpkt_put_stringb(ssh, server_pubkey)) != 0 ||
  ------------------
  |  Branch (374:6): [True: 0, False: 1]
  ------------------
  375|      1|	    (r = sshpkt_put_string(ssh, signature, slen)) != 0 ||
  ------------------
  |  Branch (375:6): [True: 0, False: 1]
  ------------------
  376|      1|	    (r = sshpkt_send(ssh)) != 0)
  ------------------
  |  Branch (376:6): [True: 0, False: 1]
  ------------------
  377|      0|		goto out;
  378|       |
  379|      1|	if ((r = kex_derive_keys(ssh, hash, hashlen, shared_secret)) != 0 ||
  ------------------
  |  Branch (379:6): [True: 0, False: 1]
  ------------------
  380|      1|	    (r = kex_send_newkeys(ssh)) != 0)
  ------------------
  |  Branch (380:6): [True: 0, False: 1]
  ------------------
  381|      0|		goto out;
  382|       |	/* retain copy of hostkey used at initial KEX */
  383|      1|	if (kex->initial_hostkey == NULL &&
  ------------------
  |  Branch (383:6): [True: 1, False: 0]
  ------------------
  384|      1|	    (r = sshkey_from_private(server_host_public,
  ------------------
  |  Branch (384:6): [True: 0, False: 1]
  ------------------
  385|      1|	    &kex->initial_hostkey)) != 0)
  386|      0|		goto out;
  387|       |	/* success */
  388|      1|out:
  389|      1|	explicit_bzero(hash, sizeof(hash));
  390|      1|	sshbuf_free(server_host_key_blob);
  391|      1|	free(signature);
  392|      1|	sshbuf_free(shared_secret);
  393|      1|	sshbuf_free(client_pubkey);
  394|      1|	sshbuf_free(server_pubkey);
  395|      1|	return r;
  396|      1|}

log_level_get:
  113|      2|{
  114|      2|	return log_level;
  115|      2|}
log_init:
  196|      1|{
  197|       |#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT)
  198|       |	struct syslog_data sdata = SYSLOG_DATA_INIT;
  199|       |#endif
  200|       |
  201|      1|	argv0 = av0;
  202|       |
  203|      1|	if (log_change_level(level) != 0) {
  ------------------
  |  Branch (203:6): [True: 0, False: 1]
  ------------------
  204|      0|		fprintf(stderr, "Unrecognized internal syslog level code %d\n",
  205|      0|		    (int) level);
  206|      0|		exit(1);
  207|      0|	}
  208|       |
  209|      1|	log_handler = NULL;
  210|      1|	log_handler_ctx = NULL;
  211|       |
  212|      1|	log_on_stderr = on_stderr;
  213|      1|	if (on_stderr)
  ------------------
  |  Branch (213:6): [True: 0, False: 1]
  ------------------
  214|      0|		return;
  215|       |
  216|      1|	switch (facility) {
  217|      0|	case SYSLOG_FACILITY_DAEMON:
  ------------------
  |  Branch (217:2): [True: 0, False: 1]
  ------------------
  218|      0|		log_facility = LOG_DAEMON;
  219|      0|		break;
  220|      0|	case SYSLOG_FACILITY_USER:
  ------------------
  |  Branch (220:2): [True: 0, False: 1]
  ------------------
  221|      0|		log_facility = LOG_USER;
  222|      0|		break;
  223|      1|	case SYSLOG_FACILITY_AUTH:
  ------------------
  |  Branch (223:2): [True: 1, False: 0]
  ------------------
  224|      1|		log_facility = LOG_AUTH;
  225|      1|		break;
  226|      0|#ifdef LOG_AUTHPRIV
  227|      0|	case SYSLOG_FACILITY_AUTHPRIV:
  ------------------
  |  Branch (227:2): [True: 0, False: 1]
  ------------------
  228|      0|		log_facility = LOG_AUTHPRIV;
  229|      0|		break;
  230|      0|#endif
  231|      0|	case SYSLOG_FACILITY_LOCAL0:
  ------------------
  |  Branch (231:2): [True: 0, False: 1]
  ------------------
  232|      0|		log_facility = LOG_LOCAL0;
  233|      0|		break;
  234|      0|	case SYSLOG_FACILITY_LOCAL1:
  ------------------
  |  Branch (234:2): [True: 0, False: 1]
  ------------------
  235|      0|		log_facility = LOG_LOCAL1;
  236|      0|		break;
  237|      0|	case SYSLOG_FACILITY_LOCAL2:
  ------------------
  |  Branch (237:2): [True: 0, False: 1]
  ------------------
  238|      0|		log_facility = LOG_LOCAL2;
  239|      0|		break;
  240|      0|	case SYSLOG_FACILITY_LOCAL3:
  ------------------
  |  Branch (240:2): [True: 0, False: 1]
  ------------------
  241|      0|		log_facility = LOG_LOCAL3;
  242|      0|		break;
  243|      0|	case SYSLOG_FACILITY_LOCAL4:
  ------------------
  |  Branch (243:2): [True: 0, False: 1]
  ------------------
  244|      0|		log_facility = LOG_LOCAL4;
  245|      0|		break;
  246|      0|	case SYSLOG_FACILITY_LOCAL5:
  ------------------
  |  Branch (246:2): [True: 0, False: 1]
  ------------------
  247|      0|		log_facility = LOG_LOCAL5;
  248|      0|		break;
  249|      0|	case SYSLOG_FACILITY_LOCAL6:
  ------------------
  |  Branch (249:2): [True: 0, False: 1]
  ------------------
  250|      0|		log_facility = LOG_LOCAL6;
  251|      0|		break;
  252|      0|	case SYSLOG_FACILITY_LOCAL7:
  ------------------
  |  Branch (252:2): [True: 0, False: 1]
  ------------------
  253|      0|		log_facility = LOG_LOCAL7;
  254|      0|		break;
  255|      0|	default:
  ------------------
  |  Branch (255:2): [True: 0, False: 1]
  ------------------
  256|      0|		fprintf(stderr,
  257|      0|		    "Unrecognized internal syslog facility code %d\n",
  258|      0|		    (int) facility);
  259|      0|		exit(1);
  260|      1|	}
  261|       |
  262|       |	/*
  263|       |	 * If an external library (eg libwrap) attempts to use syslog
  264|       |	 * immediately after reexec, syslog may be pointing to the wrong
  265|       |	 * facility, so we force an open/close of syslog here.
  266|       |	 */
  267|       |#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT)
  268|       |	openlog_r(argv0 ? argv0 : __progname, LOG_PID, log_facility, &sdata);
  269|       |	closelog_r(&sdata);
  270|       |#else
  271|      1|	openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility);
  ------------------
  |  Branch (271:10): [True: 1, False: 0]
  ------------------
  272|      1|	closelog();
  273|      1|#endif
  274|      1|}
log_change_level:
  278|      1|{
  279|       |	/* no-op if log_init has not been called */
  280|      1|	if (argv0 == NULL)
  ------------------
  |  Branch (280:6): [True: 0, False: 1]
  ------------------
  281|      0|		return 0;
  282|       |
  283|      1|	switch (new_log_level) {
  284|      0|	case SYSLOG_LEVEL_QUIET:
  ------------------
  |  Branch (284:2): [True: 0, False: 1]
  ------------------
  285|      0|	case SYSLOG_LEVEL_FATAL:
  ------------------
  |  Branch (285:2): [True: 0, False: 1]
  ------------------
  286|      1|	case SYSLOG_LEVEL_ERROR:
  ------------------
  |  Branch (286:2): [True: 1, False: 0]
  ------------------
  287|      1|	case SYSLOG_LEVEL_INFO:
  ------------------
  |  Branch (287:2): [True: 0, False: 1]
  ------------------
  288|      1|	case SYSLOG_LEVEL_VERBOSE:
  ------------------
  |  Branch (288:2): [True: 0, False: 1]
  ------------------
  289|      1|	case SYSLOG_LEVEL_DEBUG1:
  ------------------
  |  Branch (289:2): [True: 0, False: 1]
  ------------------
  290|      1|	case SYSLOG_LEVEL_DEBUG2:
  ------------------
  |  Branch (290:2): [True: 0, False: 1]
  ------------------
  291|      1|	case SYSLOG_LEVEL_DEBUG3:
  ------------------
  |  Branch (291:2): [True: 0, False: 1]
  ------------------
  292|      1|		log_level = new_log_level;
  293|      1|		return 0;
  294|      0|	default:
  ------------------
  |  Branch (294:2): [True: 0, False: 1]
  ------------------
  295|      0|		return -1;
  296|      1|	}
  297|      1|}
sshlog:
  430|  3.27k|{
  431|  3.27k|	va_list args;
  432|       |
  433|  3.27k|	va_start(args, fmt);
  434|  3.27k|	sshlogv(file, func, line, showfunc, level, suffix, fmt, args);
  435|       |	va_end(args);
  436|  3.27k|}
sshlogv:
  454|  3.30k|{
  455|  3.30k|	char tag[128], fmt2[MSGBUFSIZ + 128];
  456|  3.30k|	int forced = 0;
  457|  3.30k|	const char *cp;
  458|  3.30k|	size_t i;
  459|       |
  460|       |	/* short circuit processing early if we're not going to log anything */
  461|  3.30k|	if (nlog_verbose == 0 && level > log_level)
  ------------------
  |  Branch (461:6): [True: 3.30k, False: 0]
  |  Branch (461:27): [True: 3.27k, False: 36]
  ------------------
  462|  3.27k|		return;
  463|       |
  464|     36|	snprintf(tag, sizeof(tag), "%.48s:%.48s():%d (bin=%s, pid=%ld)",
  465|     36|	    (cp = strrchr(file, '/')) == NULL ? file : cp + 1, func, line,
  ------------------
  |  Branch (465:6): [True: 36, False: 0]
  ------------------
  466|     36|	    argv0 == NULL ? "UNKNOWN" : argv0, (long)getpid());
  ------------------
  |  Branch (466:6): [True: 0, False: 36]
  ------------------
  467|     36|	for (i = 0; i < nlog_verbose; i++) {
  ------------------
  |  Branch (467:14): [True: 0, False: 36]
  ------------------
  468|      0|		if (match_pattern_list(tag, log_verbose[i], 0) == 1) {
  ------------------
  |  Branch (468:7): [True: 0, False: 0]
  ------------------
  469|      0|			forced = 1;
  470|      0|			break;
  471|      0|		}
  472|      0|	}
  473|       |
  474|     36|	if (forced)
  ------------------
  |  Branch (474:6): [True: 0, False: 36]
  ------------------
  475|      0|		snprintf(fmt2, sizeof(fmt2), "%s: %s", tag, fmt);
  476|     36|	else if (showfunc)
  ------------------
  |  Branch (476:11): [True: 36, False: 0]
  ------------------
  477|     36|		snprintf(fmt2, sizeof(fmt2), "%s: %s", func, fmt);
  478|      0|	else
  479|      0|		strlcpy(fmt2, fmt, sizeof(fmt2));
  480|       |
  481|     36|	do_log(level, forced, suffix, fmt2, args);
  482|     36|}
log.c:do_log:
  339|     36|{
  340|       |#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT)
  341|       |	struct syslog_data sdata = SYSLOG_DATA_INIT;
  342|       |#endif
  343|     36|	char msgbuf[MSGBUFSIZ];
  344|     36|	char fmtbuf[MSGBUFSIZ];
  345|     36|	char *txt = NULL;
  346|     36|	int pri = LOG_INFO;
  347|     36|	int saved_errno = errno;
  348|     36|	log_handler_fn *tmp_handler;
  349|     36|	const char *progname = argv0 != NULL ? argv0 : __progname;
  ------------------
  |  Branch (349:25): [True: 36, False: 0]
  ------------------
  350|       |
  351|     36|	if (!force && level > log_level)
  ------------------
  |  Branch (351:6): [True: 36, False: 0]
  |  Branch (351:16): [True: 0, False: 36]
  ------------------
  352|      0|		return;
  353|       |
  354|     36|	switch (level) {
  355|     36|	case SYSLOG_LEVEL_FATAL:
  ------------------
  |  Branch (355:2): [True: 36, False: 0]
  ------------------
  356|     36|		if (!log_on_stderr)
  ------------------
  |  Branch (356:7): [True: 36, False: 0]
  ------------------
  357|     36|			txt = "fatal";
  358|     36|		pri = LOG_CRIT;
  359|     36|		break;
  360|      0|	case SYSLOG_LEVEL_ERROR:
  ------------------
  |  Branch (360:2): [True: 0, False: 36]
  ------------------
  361|      0|		if (!log_on_stderr)
  ------------------
  |  Branch (361:7): [True: 0, False: 0]
  ------------------
  362|      0|			txt = "error";
  363|      0|		pri = LOG_ERR;
  364|      0|		break;
  365|      0|	case SYSLOG_LEVEL_INFO:
  ------------------
  |  Branch (365:2): [True: 0, False: 36]
  ------------------
  366|      0|		pri = LOG_INFO;
  367|      0|		break;
  368|      0|	case SYSLOG_LEVEL_VERBOSE:
  ------------------
  |  Branch (368:2): [True: 0, False: 36]
  ------------------
  369|      0|		pri = LOG_INFO;
  370|      0|		break;
  371|      0|	case SYSLOG_LEVEL_DEBUG1:
  ------------------
  |  Branch (371:2): [True: 0, False: 36]
  ------------------
  372|      0|		txt = "debug1";
  373|      0|		pri = LOG_DEBUG;
  374|      0|		break;
  375|      0|	case SYSLOG_LEVEL_DEBUG2:
  ------------------
  |  Branch (375:2): [True: 0, False: 36]
  ------------------
  376|      0|		txt = "debug2";
  377|      0|		pri = LOG_DEBUG;
  378|      0|		break;
  379|      0|	case SYSLOG_LEVEL_DEBUG3:
  ------------------
  |  Branch (379:2): [True: 0, False: 36]
  ------------------
  380|      0|		txt = "debug3";
  381|      0|		pri = LOG_DEBUG;
  382|      0|		break;
  383|      0|	default:
  ------------------
  |  Branch (383:2): [True: 0, False: 36]
  ------------------
  384|      0|		txt = "internal error";
  385|      0|		pri = LOG_ERR;
  386|      0|		break;
  387|     36|	}
  388|     36|	if (txt != NULL && log_handler == NULL) {
  ------------------
  |  Branch (388:6): [True: 36, False: 0]
  |  Branch (388:21): [True: 36, False: 0]
  ------------------
  389|     36|		snprintf(fmtbuf, sizeof(fmtbuf), "%s: %s", txt, fmt);
  390|     36|		vsnprintf(msgbuf, sizeof(msgbuf), fmtbuf, args);
  391|     36|	} else {
  392|      0|		vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
  393|      0|	}
  394|     36|	if (suffix != NULL) {
  ------------------
  |  Branch (394:6): [True: 36, False: 0]
  ------------------
  395|     36|		snprintf(fmtbuf, sizeof(fmtbuf), "%s: %s", msgbuf, suffix);
  396|     36|		strlcpy(msgbuf, fmtbuf, sizeof(msgbuf));
  397|     36|	}
  398|     36|	strnvis(fmtbuf, msgbuf, sizeof(fmtbuf),
  399|     36|	    log_on_stderr ? LOG_STDERR_VIS : LOG_SYSLOG_VIS);
  ------------------
  |  |   69|      0|#define LOG_STDERR_VIS	(VIS_SAFE|VIS_OCTAL)
  |  |  ------------------
  |  |  |  |   60|      0|#define	VIS_SAFE	0x20	/* only encode "unsafe" characters */
  |  |  ------------------
  |  |               #define LOG_STDERR_VIS	(VIS_SAFE|VIS_OCTAL)
  |  |  ------------------
  |  |  |  |   49|      0|#define	VIS_OCTAL	0x01	/* use octal \ddd format */
  |  |  ------------------
  ------------------
              	    log_on_stderr ? LOG_STDERR_VIS : LOG_SYSLOG_VIS);
  ------------------
  |  |   68|     36|#define LOG_SYSLOG_VIS	(VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL)
  |  |  ------------------
  |  |  |  |   50|     36|#define	VIS_CSTYLE	0x02	/* use \[nrft0..] where appropriate */
  |  |  ------------------
  |  |               #define LOG_SYSLOG_VIS	(VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL)
  |  |  ------------------
  |  |  |  |   58|     36|#define	VIS_NL		0x10	/* also encode newline */
  |  |  ------------------
  |  |               #define LOG_SYSLOG_VIS	(VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL)
  |  |  ------------------
  |  |  |  |   57|     36|#define	VIS_TAB		0x08	/* also encode tab */
  |  |  ------------------
  |  |               #define LOG_SYSLOG_VIS	(VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL)
  |  |  ------------------
  |  |  |  |   49|     36|#define	VIS_OCTAL	0x01	/* use octal \ddd format */
  |  |  ------------------
  ------------------
  |  Branch (399:6): [True: 0, False: 36]
  ------------------
  400|     36|	if (log_handler != NULL) {
  ------------------
  |  Branch (400:6): [True: 0, False: 36]
  ------------------
  401|       |		/* Avoid recursion */
  402|      0|		tmp_handler = log_handler;
  403|      0|		log_handler = NULL;
  404|       |		/* Note: this sends the raw (i.e. no strnvis) log message */
  405|      0|		tmp_handler(level, force, msgbuf, log_handler_ctx);
  406|      0|		log_handler = tmp_handler;
  407|     36|	} else if (log_on_stderr) {
  ------------------
  |  Branch (407:13): [True: 0, False: 36]
  ------------------
  408|      0|		snprintf(msgbuf, sizeof msgbuf, "%s%s%.*s\r\n",
  409|      0|		    (log_on_stderr > 1) ? progname : "",
  ------------------
  |  Branch (409:7): [True: 0, False: 0]
  ------------------
  410|      0|		    (log_on_stderr > 1) ? ": " : "",
  ------------------
  |  Branch (410:7): [True: 0, False: 0]
  ------------------
  411|      0|		    (int)sizeof msgbuf - 3, fmtbuf);
  412|      0|		(void)write(log_stderr_fd, msgbuf, strlen(msgbuf));
  413|     36|	} else {
  414|       |#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT)
  415|       |		openlog_r(progname, LOG_PID, log_facility, &sdata);
  416|       |		syslog_r(pri, &sdata, "%.500s", fmtbuf);
  417|       |		closelog_r(&sdata);
  418|       |#else
  419|     36|		openlog(progname, LOG_PID, log_facility);
  420|     36|		syslog(pri, "%.500s", fmtbuf);
  421|     36|		closelog();
  422|     36|#endif
  423|     36|	}
  424|       |	errno = saved_errno;
  425|     36|}

mac_alg_list:
   85|      1|{
   86|      1|	char *ret = NULL;
   87|      1|	const struct macalg *m;
   88|      1|	char sep_str[2] = {sep, '\0'};
   89|       |
   90|     17|	for (m = macs; m->name != NULL; m++)
  ------------------
  |  Branch (90:17): [True: 16, False: 1]
  ------------------
   91|     16|		xextendf(&ret, sep_str, "%s", m->name);
   92|       |
   93|      1|	return ret;
   94|      1|}
mac_setup:
  117|      4|{
  118|      4|	const struct macalg *m;
  119|       |
  120|     12|	for (m = macs; m->name != NULL; m++) {
  ------------------
  |  Branch (120:17): [True: 12, False: 0]
  ------------------
  121|     12|		if (strcmp(name, m->name) != 0)
  ------------------
  |  Branch (121:7): [True: 8, False: 4]
  ------------------
  122|      8|			continue;
  123|      4|		if (mac != NULL)
  ------------------
  |  Branch (123:7): [True: 4, False: 0]
  ------------------
  124|      4|			return mac_setup_by_alg(mac, m);
  125|      0|		return 0;
  126|      4|	}
  127|      0|	return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  128|      4|}
mac_init:
  132|      4|{
  133|      4|	if (mac->key == NULL)
  ------------------
  |  Branch (133:6): [True: 0, False: 4]
  ------------------
  134|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  135|      4|	switch (mac->type) {
  136|      4|	case SSH_DIGEST:
  ------------------
  |  |   44|      4|#define SSH_DIGEST	1	/* SSH_DIGEST_XXX */
  ------------------
  |  Branch (136:2): [True: 4, False: 0]
  ------------------
  137|      4|		if (mac->hmac_ctx == NULL ||
  ------------------
  |  Branch (137:7): [True: 0, False: 4]
  ------------------
  138|      4|		    ssh_hmac_init(mac->hmac_ctx, mac->key, mac->key_len) < 0)
  ------------------
  |  Branch (138:7): [True: 0, False: 4]
  ------------------
  139|      0|			return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  140|      4|		return 0;
  141|      0|	case SSH_UMAC:
  ------------------
  |  |   45|      0|#define SSH_UMAC	2	/* UMAC (not integrated with OpenSSL) */
  ------------------
  |  Branch (141:2): [True: 0, False: 4]
  ------------------
  142|      0|		if ((mac->umac_ctx = umac_new(mac->key)) == NULL)
  ------------------
  |  Branch (142:7): [True: 0, False: 0]
  ------------------
  143|      0|			return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  144|      0|		return 0;
  145|      0|	case SSH_UMAC128:
  ------------------
  |  |   46|      0|#define SSH_UMAC128	3
  ------------------
  |  Branch (145:2): [True: 0, False: 4]
  ------------------
  146|      0|		if ((mac->umac_ctx = umac128_new(mac->key)) == NULL)
  ------------------
  |  Branch (146:7): [True: 0, False: 0]
  ------------------
  147|      0|			return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  148|      0|		return 0;
  149|      0|	default:
  ------------------
  |  Branch (149:2): [True: 0, False: 4]
  ------------------
  150|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  151|      4|	}
  152|      4|}
mac_compute:
  158|  1.21k|{
  159|  1.21k|	static union {
  160|  1.21k|		u_char m[SSH_DIGEST_MAX_LENGTH];
  161|  1.21k|		uint64_t for_align;
  162|  1.21k|	} u;
  163|  1.21k|	u_char b[4];
  164|  1.21k|	u_char nonce[8];
  165|       |
  166|  1.21k|	if (mac->mac_len > sizeof(u))
  ------------------
  |  Branch (166:6): [True: 0, False: 1.21k]
  ------------------
  167|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  168|       |
  169|  1.21k|	switch (mac->type) {
  170|  1.21k|	case SSH_DIGEST:
  ------------------
  |  |   44|  1.21k|#define SSH_DIGEST	1	/* SSH_DIGEST_XXX */
  ------------------
  |  Branch (170:2): [True: 1.21k, False: 0]
  ------------------
  171|  1.21k|		put_u32(b, seqno);
  172|       |		/* reset HMAC context */
  173|  1.21k|		if (ssh_hmac_init(mac->hmac_ctx, NULL, 0) < 0 ||
  ------------------
  |  Branch (173:7): [True: 0, False: 1.21k]
  ------------------
  174|  1.21k|		    ssh_hmac_update(mac->hmac_ctx, b, sizeof(b)) < 0 ||
  ------------------
  |  Branch (174:7): [True: 0, False: 1.21k]
  ------------------
  175|  1.21k|		    ssh_hmac_update(mac->hmac_ctx, data, datalen) < 0 ||
  ------------------
  |  Branch (175:7): [True: 0, False: 1.21k]
  ------------------
  176|  1.21k|		    ssh_hmac_final(mac->hmac_ctx, u.m, sizeof(u.m)) < 0)
  ------------------
  |  Branch (176:7): [True: 0, False: 1.21k]
  ------------------
  177|      0|			return SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  178|  1.21k|		break;
  179|  1.21k|	case SSH_UMAC:
  ------------------
  |  |   45|      0|#define SSH_UMAC	2	/* UMAC (not integrated with OpenSSL) */
  ------------------
  |  Branch (179:2): [True: 0, False: 1.21k]
  ------------------
  180|      0|		POKE_U64(nonce, seqno);
  ------------------
  |  |  360|      0|	do { \
  |  |  361|      0|		const uint64_t __v = (v); \
  |  |  362|      0|		((u_char *)(p))[0] = (__v >> 56) & 0xff; \
  |  |  363|      0|		((u_char *)(p))[1] = (__v >> 48) & 0xff; \
  |  |  364|      0|		((u_char *)(p))[2] = (__v >> 40) & 0xff; \
  |  |  365|      0|		((u_char *)(p))[3] = (__v >> 32) & 0xff; \
  |  |  366|      0|		((u_char *)(p))[4] = (__v >> 24) & 0xff; \
  |  |  367|      0|		((u_char *)(p))[5] = (__v >> 16) & 0xff; \
  |  |  368|      0|		((u_char *)(p))[6] = (__v >> 8) & 0xff; \
  |  |  369|      0|		((u_char *)(p))[7] = __v & 0xff; \
  |  |  370|      0|	} while (0)
  |  |  ------------------
  |  |  |  Branch (370:11): [Folded, False: 0]
  |  |  ------------------
  ------------------
  181|      0|		umac_update(mac->umac_ctx, data, datalen);
  182|      0|		umac_final(mac->umac_ctx, u.m, nonce);
  183|      0|		break;
  184|      0|	case SSH_UMAC128:
  ------------------
  |  |   46|      0|#define SSH_UMAC128	3
  ------------------
  |  Branch (184:2): [True: 0, False: 1.21k]
  ------------------
  185|      0|		put_u64(nonce, seqno);
  186|      0|		umac128_update(mac->umac_ctx, data, datalen);
  187|      0|		umac128_final(mac->umac_ctx, u.m, nonce);
  188|      0|		break;
  189|      0|	default:
  ------------------
  |  Branch (189:2): [True: 0, False: 1.21k]
  ------------------
  190|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  191|  1.21k|	}
  192|  1.21k|	if (digest != NULL) {
  ------------------
  |  Branch (192:6): [True: 1.21k, False: 0]
  ------------------
  193|  1.21k|		if (dlen > mac->mac_len)
  ------------------
  |  Branch (193:7): [True: 1.21k, False: 0]
  ------------------
  194|  1.21k|			dlen = mac->mac_len;
  195|  1.21k|		memcpy(digest, u.m, dlen);
  196|  1.21k|	}
  197|  1.21k|	return 0;
  198|  1.21k|}
mac_check:
  204|    408|{
  205|    408|	u_char ourmac[SSH_DIGEST_MAX_LENGTH];
  206|    408|	int r;
  207|       |
  208|    408|	if (mac->mac_len > mlen)
  ------------------
  |  Branch (208:6): [True: 0, False: 408]
  ------------------
  209|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  210|    408|	if ((r = mac_compute(mac, seqno, data, dlen,
  ------------------
  |  Branch (210:6): [True: 0, False: 408]
  ------------------
  211|    408|	    ourmac, sizeof(ourmac))) != 0)
  212|      0|		return r;
  213|    408|	if (timingsafe_bcmp(ourmac, theirmac, mac->mac_len) != 0)
  ------------------
  |  Branch (213:6): [True: 0, False: 408]
  ------------------
  214|      0|		return SSH_ERR_MAC_INVALID;
  ------------------
  |  |   54|      0|#define SSH_ERR_MAC_INVALID			-30
  ------------------
  215|    408|	return 0;
  216|    408|}
mac.c:mac_setup_by_alg:
   98|      4|{
   99|      4|	mac->type = macalg->type;
  100|      4|	if (mac->type == SSH_DIGEST) {
  ------------------
  |  |   44|      4|#define SSH_DIGEST	1	/* SSH_DIGEST_XXX */
  ------------------
  |  Branch (100:6): [True: 4, False: 0]
  ------------------
  101|      4|		if ((mac->hmac_ctx = ssh_hmac_start(macalg->alg)) == NULL)
  ------------------
  |  Branch (101:7): [True: 0, False: 4]
  ------------------
  102|      0|			return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  103|      4|		mac->key_len = mac->mac_len = ssh_hmac_bytes(macalg->alg);
  104|      4|	} else {
  105|      0|		mac->mac_len = macalg->len / 8;
  106|      0|		mac->key_len = macalg->key_len / 8;
  107|      0|		mac->umac_ctx = NULL;
  108|      0|	}
  109|      4|	if (macalg->truncatebits != 0)
  ------------------
  |  Branch (109:6): [True: 0, False: 4]
  ------------------
  110|      0|		mac->mac_len = macalg->truncatebits / 8;
  111|      4|	mac->etm = macalg->etm;
  112|      4|	return 0;
  113|      4|}

match_pattern:
   83|    959|{
   84|    959|	size_t M;
   85|    959|	size_t i;
   86|    959|	char *states, *next_states, *tmp;
   87|    959|	int active, matched = 0;
   88|       |
   89|       |	/* trivial case: empty pattern vs empty input */
   90|    959|	if ((M = strlen(pattern)) == 0)
  ------------------
  |  Branch (90:6): [True: 0, False: 959]
  ------------------
   91|      0|		return *s == '\0';
   92|       |
   93|       |	/* A state for each pattern character, plus one final accepting state */
   94|    959|	states = xcalloc(M + 1, sizeof(*states));
   95|    959|	next_states = xcalloc(M + 1, sizeof(*next_states));
   96|       |
   97|       |	/* Initial state: state 0 is active */
   98|    959|	states[0] = 1;
   99|       |	/* Other states might be reachable now if the pattern starts with '*' */
  100|    959|	epsilon_closure(states, pattern, M);
  101|       |
  102|  4.64k|	for (; *s; s++) {
  ------------------
  |  Branch (102:9): [True: 4.56k, False: 75]
  ------------------
  103|  4.56k|		memset(next_states, 0, M + 1);
  104|       |
  105|       |		/* Calculate the reachable next states given the input char */
  106|   113k|		for (i = 0; i < M; i++) {
  ------------------
  |  Branch (106:15): [True: 109k, False: 4.56k]
  ------------------
  107|   109k|			if (!states[i])
  ------------------
  |  Branch (107:8): [True: 104k, False: 4.55k]
  ------------------
  108|   104k|				continue;
  109|  4.55k|			if (pattern[i] == '*') {
  ------------------
  |  Branch (109:8): [True: 10, False: 4.54k]
  ------------------
  110|       |				/*
  111|       |				 * '*' matches any character, so we can
  112|       |				 * stay in state i
  113|       |				 */
  114|     10|				next_states[i] = 1;
  115|  4.54k|			} else if (pattern[i] == '?' || pattern[i] == *s) {
  ------------------
  |  Branch (115:15): [True: 0, False: 4.54k]
  |  Branch (115:36): [True: 3.67k, False: 872]
  ------------------
  116|       |				/*
  117|       |				 * '?' matches any character, or we have
  118|       |				 * a literal match.
  119|       |				 */
  120|  3.67k|				next_states[i + 1] = 1;
  121|  3.67k|			}
  122|  4.55k|		}
  123|       |
  124|       |		/* Expand the reachable next states with epsilon transitions */
  125|  4.56k|		epsilon_closure(next_states, pattern, M);
  126|       |
  127|       |		/* Swap states and next_states */
  128|  4.56k|		tmp = states;
  129|  4.56k|		states = next_states;
  130|  4.56k|		next_states = tmp;
  131|       |
  132|       |		/* Check if we have any active pattern states left */
  133|  4.56k|		active = 0;
  134|  60.6k|		for (i = 0; i <= M; i++) {
  ------------------
  |  Branch (134:15): [True: 59.7k, False: 884]
  ------------------
  135|  59.7k|			if (states[i]) {
  ------------------
  |  Branch (135:8): [True: 3.68k, False: 56.0k]
  ------------------
  136|  3.68k|				active = 1;
  137|  3.68k|				break;
  138|  3.68k|			}
  139|  59.7k|		}
  140|  4.56k|		if (!active)
  ------------------
  |  Branch (140:7): [True: 884, False: 3.68k]
  ------------------
  141|    884|			goto out; /* No active states, fail early */
  142|  4.56k|	}
  143|       |	/*
  144|       |	 * We matched only if we ended up in the final, accepting state
  145|       |	 * after consuming all the input.
  146|       |	 */
  147|     75|	matched = states[M];
  148|    959| out:
  149|    959|	free(states);
  150|    959|	free(next_states);
  151|    959|	return matched;
  152|     75|}
match_pattern_list:
  162|     81|{
  163|     81|	char sub[1024];
  164|     81|	int negated;
  165|     81|	int got_positive;
  166|     81|	u_int i, subi, len = strlen(pattern);
  167|       |
  168|     81|	got_positive = 0;
  169|  1.04k|	for (i = 0; i < len;) {
  ------------------
  |  Branch (169:14): [True: 959, False: 81]
  ------------------
  170|       |		/* Check if the subpattern is negated. */
  171|    959|		if (pattern[i] == '!') {
  ------------------
  |  Branch (171:7): [True: 0, False: 959]
  ------------------
  172|      0|			negated = 1;
  173|      0|			i++;
  174|      0|		} else
  175|    959|			negated = 0;
  176|       |
  177|       |		/*
  178|       |		 * Extract the subpattern up to a comma or end.  Convert the
  179|       |		 * subpattern to lowercase.
  180|       |		 */
  181|    959|		for (subi = 0;
  182|  23.5k|		    i < len && subi < sizeof(sub) - 1 && pattern[i] != ',';
  ------------------
  |  Branch (182:7): [True: 23.5k, False: 81]
  |  Branch (182:18): [True: 23.5k, False: 0]
  |  Branch (182:44): [True: 22.6k, False: 878]
  ------------------
  183|  22.6k|		    subi++, i++)
  184|  22.6k|			sub[subi] = dolower && isupper((u_char)pattern[i]) ?
  ------------------
  |  Branch (184:16): [True: 0, False: 22.6k]
  |  Branch (184:27): [True: 0, False: 0]
  ------------------
  185|  22.6k|			    tolower((u_char)pattern[i]) : pattern[i];
  ------------------
  |  Branch (185:8): [True: 0, False: 0]
  |  Branch (185:8): [True: 0, False: 0]
  |  Branch (185:8): [Folded, False: 0]
  ------------------
  186|       |		/* If subpattern too long, return failure (no match). */
  187|    959|		if (subi >= sizeof(sub) - 1)
  ------------------
  |  Branch (187:7): [True: 0, False: 959]
  ------------------
  188|      0|			return 0;
  189|       |
  190|       |		/* If the subpattern was terminated by a comma, then skip it. */
  191|    959|		if (i < len && pattern[i] == ',')
  ------------------
  |  Branch (191:7): [True: 878, False: 81]
  |  Branch (191:18): [True: 878, False: 0]
  ------------------
  192|    878|			i++;
  193|       |
  194|       |		/* Null-terminate the subpattern. */
  195|    959|		sub[subi] = '\0';
  196|       |
  197|       |		/* Try to match the subpattern against the string. */
  198|    959|		if (match_pattern(string, sub)) {
  ------------------
  |  Branch (198:7): [True: 61, False: 898]
  ------------------
  199|     61|			if (negated)
  ------------------
  |  Branch (199:8): [True: 0, False: 61]
  ------------------
  200|      0|				return -1;		/* Negative */
  201|     61|			else
  202|     61|				got_positive = 1;	/* Positive */
  203|     61|		}
  204|    959|	}
  205|       |
  206|       |	/*
  207|       |	 * Return success if got a positive match.  If there was a negative
  208|       |	 * match, we have already returned -1 and never get here.
  209|       |	 */
  210|     81|	return got_positive;
  211|     81|}
match_list:
  314|     26|{
  315|     26|	char *sproposals[MAX_PROP];
  316|     26|	char *c, *s, *p, *ret, *cp, *sp;
  317|     26|	int i, j, nproposals;
  318|       |
  319|     26|	c = cp = xstrdup(client);
  320|     26|	s = sp = xstrdup(server);
  321|       |
  322|     62|	for ((p = strsep(&sp, SEP)), i=0; p && *p != '\0';
  ------------------
  |  |  311|     26|#define	SEP	","
  ------------------
  |  Branch (322:36): [True: 36, False: 26]
  |  Branch (322:41): [True: 36, False: 0]
  ------------------
  323|     36|	    (p = strsep(&sp, SEP)), i++) {
  ------------------
  |  |  311|     36|#define	SEP	","
  ------------------
  324|     36|		if (i < MAX_PROP)
  ------------------
  |  |  310|     36|#define	MAX_PROP	40
  ------------------
  |  Branch (324:7): [True: 36, False: 0]
  ------------------
  325|     36|			sproposals[i] = p;
  326|      0|		else
  327|      0|			break;
  328|     36|	}
  329|     26|	nproposals = i;
  330|       |
  331|     40|	for ((p = strsep(&cp, SEP)), i=0; p && *p != '\0';
  ------------------
  |  |  311|     26|#define	SEP	","
  ------------------
  |  Branch (331:36): [True: 34, False: 6]
  |  Branch (331:41): [True: 34, False: 0]
  ------------------
  332|     34|	    (p = strsep(&cp, SEP)), i++) {
  ------------------
  |  |  311|     14|#define	SEP	","
  ------------------
  333|     50|		for (j = 0; j < nproposals; j++) {
  ------------------
  |  Branch (333:15): [True: 36, False: 14]
  ------------------
  334|     36|			if (strcmp(p, sproposals[j]) == 0) {
  ------------------
  |  Branch (334:8): [True: 20, False: 16]
  ------------------
  335|     20|				ret = xstrdup(p);
  336|     20|				if (next != NULL)
  ------------------
  |  Branch (336:9): [True: 0, False: 20]
  ------------------
  337|      0|					*next = (cp == NULL) ?
  ------------------
  |  Branch (337:14): [True: 0, False: 0]
  ------------------
  338|      0|					    strlen(c) : (u_int)(cp - c);
  339|     20|				free(c);
  340|     20|				free(s);
  341|     20|				return ret;
  342|     20|			}
  343|     36|		}
  344|     34|	}
  345|      6|	if (next != NULL)
  ------------------
  |  Branch (345:6): [True: 0, False: 6]
  ------------------
  346|      0|		*next = strlen(c);
  347|      6|	free(c);
  348|      6|	free(s);
  349|       |	return NULL;
  350|     26|}
match_filter_denylist:
  394|      2|{
  395|      2|	return filter_list(proposal, filter, 1);
  396|      2|}
match_filter_allowlist:
  404|      5|{
  405|      5|	return filter_list(proposal, filter, 0);
  406|      5|}
match.c:epsilon_closure:
   62|  5.52k|{
   63|  5.52k|	size_t i;
   64|       |
   65|       |	/* only need a forward pass as there are no back jumps in our grammar */
   66|   137k|	for (i = 0; i < M; i++) {
  ------------------
  |  Branch (66:14): [True: 132k, False: 5.52k]
  ------------------
   67|   132k|		if (!states[i] || pattern[i] != '*')
  ------------------
  |  Branch (67:7): [True: 127k, False: 4.56k]
  |  Branch (67:21): [True: 4.55k, False: 12]
  ------------------
   68|   132k|			continue;
   69|       |		/*
   70|       |		 * State i is active, and pattern[i] is '*', so we can
   71|       |		 * epsilon-transition to i+1.
   72|       |		 */
   73|     12|		states[i + 1] = 1;
   74|     12|	}
   75|  5.52k|}
match.c:filter_list:
  361|      7|{
  362|      7|	size_t len = strlen(proposal) + 1;
  363|      7|	char *fix_prop = malloc(len);
  364|      7|	char *orig_prop = strdup(proposal);
  365|      7|	char *cp, *tmp;
  366|      7|	int r;
  367|       |
  368|      7|	if (fix_prop == NULL || orig_prop == NULL) {
  ------------------
  |  Branch (368:6): [True: 0, False: 7]
  |  Branch (368:26): [True: 0, False: 7]
  ------------------
  369|      0|		free(orig_prop);
  370|      0|		free(fix_prop);
  371|      0|		return NULL;
  372|      0|	}
  373|       |
  374|      7|	tmp = orig_prop;
  375|      7|	*fix_prop = '\0';
  376|     67|	while ((cp = strsep(&tmp, ",")) != NULL) {
  ------------------
  |  Branch (376:9): [True: 60, False: 7]
  ------------------
  377|     60|		r = match_pattern_list(cp, filter, 0);
  378|     60|		if ((denylist && r != 1) || (!denylist && r == 1)) {
  ------------------
  |  Branch (378:8): [True: 6, False: 54]
  |  Branch (378:20): [True: 2, False: 4]
  |  Branch (378:32): [True: 54, False: 4]
  |  Branch (378:45): [True: 54, False: 0]
  ------------------
  379|     56|			if (*fix_prop != '\0')
  ------------------
  |  Branch (379:8): [True: 49, False: 7]
  ------------------
  380|     49|				strlcat(fix_prop, ",", len);
  381|     56|			strlcat(fix_prop, cp, len);
  382|     56|		}
  383|     60|	}
  384|      7|	free(orig_prop);
  385|      7|	return fix_prop;
  386|      7|}

tilde_expand:
 1277|      4|{
 1278|      4|	char *ocopy = NULL, *copy, *s = NULL;
 1279|      4|	const char *path = NULL, *user = NULL;
 1280|      4|	struct passwd *pw;
 1281|      4|	size_t len;
 1282|      4|	int ret = -1, r, slash;
 1283|       |
 1284|      4|	*retp = NULL;
 1285|      4|	if (*filename != '~') {
  ------------------
  |  Branch (1285:6): [True: 4, False: 0]
  ------------------
 1286|      4|		*retp = xstrdup(filename);
 1287|      4|		return 0;
 1288|      4|	}
 1289|      0|	ocopy = copy = xstrdup(filename + 1);
 1290|       |
 1291|      0|	if (*copy == '\0')				/* ~ */
  ------------------
  |  Branch (1291:6): [True: 0, False: 0]
  ------------------
 1292|      0|		path = NULL;
 1293|      0|	else if (*copy == '/') {
  ------------------
  |  Branch (1293:11): [True: 0, False: 0]
  ------------------
 1294|      0|		copy += strspn(copy, "/");
 1295|      0|		if (*copy == '\0')
  ------------------
  |  Branch (1295:7): [True: 0, False: 0]
  ------------------
 1296|      0|			path = NULL;			/* ~/ */
 1297|      0|		else
 1298|      0|			path = copy;			/* ~/path */
 1299|      0|	} else {
 1300|      0|		user = copy;
 1301|      0|		if ((path = strchr(copy, '/')) != NULL) {
  ------------------
  |  Branch (1301:7): [True: 0, False: 0]
  ------------------
 1302|      0|			copy[path - copy] = '\0';
 1303|      0|			path++;
 1304|      0|			path += strspn(path, "/");
 1305|      0|			if (*path == '\0')		/* ~user/ */
  ------------------
  |  Branch (1305:8): [True: 0, False: 0]
  ------------------
 1306|      0|				path = NULL;
 1307|       |			/* else				 ~user/path */
 1308|      0|		}
 1309|       |		/* else					~user */
 1310|      0|	}
 1311|      0|	if (user != NULL) {
  ------------------
  |  Branch (1311:6): [True: 0, False: 0]
  ------------------
 1312|      0|		if ((pw = getpwnam(user)) == NULL) {
  ------------------
  |  Branch (1312:7): [True: 0, False: 0]
  ------------------
 1313|      0|			error_f("No such user %s", user);
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
 1314|      0|			goto out;
 1315|      0|		}
 1316|      0|	} else if ((pw = getpwuid(uid)) == NULL) {
  ------------------
  |  Branch (1316:13): [True: 0, False: 0]
  ------------------
 1317|      0|		error_f("No such uid %ld", (long)uid);
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
 1318|      0|		goto out;
 1319|      0|	}
 1320|       |
 1321|       |	/* Make sure directory has a trailing '/' */
 1322|      0|	slash = (len = strlen(pw->pw_dir)) == 0 || pw->pw_dir[len - 1] != '/';
  ------------------
  |  Branch (1322:10): [True: 0, False: 0]
  |  Branch (1322:45): [True: 0, False: 0]
  ------------------
 1323|       |
 1324|      0|	if ((r = xasprintf(&s, "%s%s%s", pw->pw_dir,
  ------------------
  |  Branch (1324:6): [True: 0, False: 0]
  ------------------
 1325|      0|	    slash ? "/" : "", path != NULL ? path : "")) <= 0) {
  ------------------
  |  Branch (1325:6): [True: 0, False: 0]
  |  Branch (1325:24): [True: 0, False: 0]
  ------------------
 1326|      0|		error_f("xasprintf failed");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
 1327|      0|		goto out;
 1328|      0|	}
 1329|      0|	if (r >= PATH_MAX) {
  ------------------
  |  Branch (1329:6): [True: 0, False: 0]
  ------------------
 1330|      0|		error_f("Path too long");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
 1331|      0|		goto out;
 1332|      0|	}
 1333|       |	/* success */
 1334|      0|	ret = 0;
 1335|      0|	*retp = s;
 1336|      0|	s = NULL;
 1337|      0| out:
 1338|      0|	free(s);
 1339|      0|	free(ocopy);
 1340|      0|	return ret;
 1341|      0|}
tilde_expand_filename:
 1345|      4|{
 1346|      4|	char *ret;
 1347|       |
 1348|      4|	if (tilde_expand(filename, uid, &ret) != 0)
  ------------------
  |  Branch (1348:6): [True: 0, False: 4]
  ------------------
 1349|      0|		cleanup_exit(255);
 1350|      4|	return ret;
 1351|      4|}
xextendf:
 1656|     87|{
 1657|     87|	va_list ap;
 1658|     87|	char *tmp1, *tmp2;
 1659|       |
 1660|     87|	va_start(ap, fmt);
 1661|     87|	xvasprintf(&tmp1, fmt, ap);
 1662|     87|	va_end(ap);
 1663|       |
 1664|     87|	if (*sp == NULL || **sp == '\0') {
  ------------------
  |  Branch (1664:6): [True: 6, False: 81]
  |  Branch (1664:21): [True: 0, False: 81]
  ------------------
 1665|      6|		free(*sp);
 1666|      6|		*sp = tmp1;
 1667|      6|		return;
 1668|      6|	}
 1669|     81|	xasprintf(&tmp2, "%s%s%s", *sp, sep == NULL ? "" : sep, tmp1);
  ------------------
  |  Branch (1669:34): [True: 0, False: 81]
  ------------------
 1670|     81|	free(tmp1);
 1671|     81|	free(*sp);
 1672|     81|	*sp = tmp2;
 1673|     81|}
put_u32:
 1751|  1.21k|{
 1752|  1.21k|	u_char *p = (u_char *)vp;
 1753|       |
 1754|  1.21k|	p[0] = (u_char)(v >> 24) & 0xff;
 1755|  1.21k|	p[1] = (u_char)(v >> 16) & 0xff;
 1756|  1.21k|	p[2] = (u_char)(v >> 8) & 0xff;
 1757|  1.21k|	p[3] = (u_char)v & 0xff;
 1758|  1.21k|}
monotime_ts:
 1801|    703|{
 1802|    703|	struct timeval tv;
 1803|    703|#if defined(HAVE_CLOCK_GETTIME) && (defined(CLOCK_BOOTTIME) || \
 1804|    703|    defined(CLOCK_MONOTONIC) || defined(CLOCK_REALTIME))
 1805|    703|	static int gettime_failed = 0;
 1806|       |
 1807|    703|	if (!gettime_failed) {
  ------------------
  |  Branch (1807:6): [True: 703, False: 0]
  ------------------
 1808|    703|# ifdef CLOCK_BOOTTIME
 1809|    703|		if (clock_gettime(CLOCK_BOOTTIME, ts) == 0)
  ------------------
  |  Branch (1809:7): [True: 703, False: 0]
  ------------------
 1810|    703|			return;
 1811|      0|# endif /* CLOCK_BOOTTIME */
 1812|      0|# ifdef CLOCK_MONOTONIC
 1813|      0|		if (clock_gettime(CLOCK_MONOTONIC, ts) == 0)
  ------------------
  |  Branch (1813:7): [True: 0, False: 0]
  ------------------
 1814|      0|			return;
 1815|      0|# endif /* CLOCK_MONOTONIC */
 1816|      0|# ifdef CLOCK_REALTIME
 1817|       |		/* Not monotonic, but we're almost out of options here. */
 1818|      0|		if (clock_gettime(CLOCK_REALTIME, ts) == 0)
  ------------------
  |  Branch (1818:7): [True: 0, False: 0]
  ------------------
 1819|      0|			return;
 1820|      0|# endif /* CLOCK_REALTIME */
 1821|      0|		debug3("clock_gettime: %s", strerror(errno));
  ------------------
  |  |  109|      0|#define debug3(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
 1822|      0|		gettime_failed = 1;
 1823|      0|	}
 1824|      0|#endif /* HAVE_CLOCK_GETTIME && (BOOTTIME || MONOTONIC || REALTIME) */
 1825|      0|	gettimeofday(&tv, NULL);
 1826|      0|	ts->tv_sec = tv.tv_sec;
 1827|      0|	ts->tv_nsec = (long)tv.tv_usec * 1000;
 1828|      0|}
monotime:
 1842|      4|{
 1843|      4|	struct timespec ts;
 1844|       |
 1845|      4|	monotime_ts(&ts);
 1846|      4|	return (ts.tv_sec);
 1847|      4|}
monotime_double:
 1851|    699|{
 1852|    699|	struct timespec ts;
 1853|       |
 1854|    699|	monotime_ts(&ts);
 1855|    699|	return (double)ts.tv_sec + (double)ts.tv_nsec / 1000000000.0;
 1856|    699|}
path_absolute:
 2670|      4|{
 2671|      4|	return (*path == '/') ? 1 : 0;
  ------------------
  |  Branch (2671:9): [True: 4, False: 0]
  ------------------
 2672|      4|}
opt_array_append2:
 2758|      6|{
 2759|       |
 2760|      6|	if (*lp >= INT_MAX)
  ------------------
  |  Branch (2760:6): [True: 0, False: 6]
  ------------------
 2761|      0|		fatal("%s line %d: Too many %s entries", file, line, directive);
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
 2762|       |
 2763|      6|	if (iarray != NULL) {
  ------------------
  |  Branch (2763:6): [True: 4, False: 2]
  ------------------
 2764|      4|		*iarray = xrecallocarray(*iarray, *lp, *lp + 1,
 2765|      4|		    sizeof(**iarray));
 2766|      4|		(*iarray)[*lp] = i;
 2767|      4|	}
 2768|       |
 2769|      6|	*array = xrecallocarray(*array, *lp, *lp + 1, sizeof(**array));
 2770|      6|	(*array)[*lp] = xstrdup(s);
 2771|      6|	(*lp)++;
 2772|      6|}
opt_array_append:
 2777|      2|{
 2778|       |	opt_array_append2(file, line, directive, array, NULL, lp, s, 0);
 2779|      2|}

arc4random:
  208|     53|{
  209|     53|	uint32_t val;
  210|       |
  211|     53|	_ARC4_LOCK();
  212|     53|	_rs_random_u32(&val);
  213|     53|	_ARC4_UNLOCK();
  214|     53|	return val;
  215|     53|}
arc4random_buf:
  225|    815|{
  226|    815|	_ARC4_LOCK();
  227|    815|	_rs_random_buf(buf, n);
  228|    815|	_ARC4_UNLOCK();
  229|    815|}
arc4random.c:_rs_random_u32:
  194|     53|{
  195|     53|	u_char *keystream;
  196|       |
  197|     53|	_rs_stir_if_needed(sizeof(*val));
  198|     53|	if (rs->rs_have < sizeof(*val))
  ------------------
  |  Branch (198:6): [True: 1, False: 52]
  ------------------
  199|      1|		_rs_rekey(NULL, 0);
  200|     53|	keystream = rsx->rs_buf + sizeof(rsx->rs_buf) - rs->rs_have;
  201|     53|	memcpy(val, keystream, sizeof(*val));
  202|     53|	memset(keystream, 0, sizeof(*val));
  203|     53|	rs->rs_have -= sizeof(*val);
  204|     53|}
arc4random.c:_rs_stir_if_needed:
  135|    868|{
  136|    868|	_rs_forkdetect();
  137|    868|	if (!rs || rs->rs_count <= len)
  ------------------
  |  Branch (137:6): [True: 1, False: 867]
  |  Branch (137:13): [True: 0, False: 867]
  ------------------
  138|      1|		_rs_stir();
  139|    868|	if (rs->rs_count <= len)
  ------------------
  |  Branch (139:6): [True: 0, False: 868]
  ------------------
  140|      0|		rs->rs_count = 0;
  141|    868|	else
  142|    868|		rs->rs_count -= len;
  143|    868|}
arc4random.c:_rs_stir:
  110|      1|{
  111|      1|	u_char rnd[KEYSZ + IVSZ];
  112|      1|	uint32_t rekey_fuzz = 0;
  113|       |
  114|      1|	if (getentropy(rnd, sizeof rnd) == -1)
  ------------------
  |  |   53|      1|#define getentropy(x, y) (_ssh_compat_getentropy((x), (y)))
  ------------------
  |  Branch (114:6): [True: 0, False: 1]
  ------------------
  115|      0|		_getentropy_fail();
  116|       |
  117|      1|	if (!rs)
  ------------------
  |  Branch (117:6): [True: 1, False: 0]
  ------------------
  118|      1|		_rs_init(rnd, sizeof(rnd));
  119|      0|	else
  120|      0|		_rs_rekey(rnd, sizeof(rnd));
  121|      1|	explicit_bzero(rnd, sizeof(rnd));	/* discard source seed */
  122|       |
  123|       |	/* invalidate rs_buf */
  124|      1|	rs->rs_have = 0;
  125|      1|	memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
  126|       |
  127|       |	/* rekey interval should not be predictable */
  128|      1|	chacha_encrypt_bytes(&rsx->rs_chacha, (uint8_t *)&rekey_fuzz,
  129|      1|	    (uint8_t *)&rekey_fuzz, sizeof(rekey_fuzz));
  130|      1|	rs->rs_count = REKEY_BASE + (rekey_fuzz % REKEY_BASE);
  ------------------
  |  |   73|      1|#define REKEY_BASE	(1024*1024) /* NB. should be a power of 2 */
  ------------------
              	rs->rs_count = REKEY_BASE + (rekey_fuzz % REKEY_BASE);
  ------------------
  |  |   73|      1|#define REKEY_BASE	(1024*1024) /* NB. should be a power of 2 */
  ------------------
  131|      1|}
arc4random.c:_rs_init:
   95|      9|{
   96|      9|	if (n < KEYSZ + IVSZ)
  ------------------
  |  |   68|      9|#define KEYSZ	32
  ------------------
              	if (n < KEYSZ + IVSZ)
  ------------------
  |  |   69|      9|#define IVSZ	8
  ------------------
  |  Branch (96:6): [True: 0, False: 9]
  ------------------
   97|      0|		return;
   98|       |
   99|      9|	if (rs == NULL) {
  ------------------
  |  Branch (99:6): [True: 1, False: 8]
  ------------------
  100|      1|		if (_rs_allocate(&rs, &rsx) == -1)
  ------------------
  |  Branch (100:7): [True: 0, False: 1]
  ------------------
  101|      0|			_exit(1);
  102|      1|	}
  103|       |
  104|      9|	chacha_keysetup(&rsx->rs_chacha, buf, KEYSZ * 8);
  ------------------
  |  |   68|      9|#define KEYSZ	32
  ------------------
  105|      9|	chacha_ivsetup(&rsx->rs_chacha, buf + KEYSZ);
  ------------------
  |  |   68|      9|#define KEYSZ	32
  ------------------
  106|      9|}
arc4random.c:_rs_rekey:
  147|      8|{
  148|       |#ifndef KEYSTREAM_ONLY
  149|       |	memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
  150|       |#endif
  151|       |	/* fill rs_buf with the keystream */
  152|      8|	chacha_encrypt_bytes(&rsx->rs_chacha, rsx->rs_buf,
  153|      8|	    rsx->rs_buf, sizeof(rsx->rs_buf));
  154|       |	/* mix in optional user provided data */
  155|      8|	if (dat) {
  ------------------
  |  Branch (155:6): [True: 0, False: 8]
  ------------------
  156|      0|		size_t i, m;
  157|       |
  158|      0|		m = minimum(datlen, KEYSZ + IVSZ);
  ------------------
  |  |   60|      0|#define minimum(a, b) ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (60:24): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  159|      0|		for (i = 0; i < m; i++)
  ------------------
  |  Branch (159:15): [True: 0, False: 0]
  ------------------
  160|      0|			rsx->rs_buf[i] ^= dat[i];
  161|      0|	}
  162|       |	/* immediately reinit for backtracking resistance */
  163|      8|	_rs_init(rsx->rs_buf, KEYSZ + IVSZ);
  ------------------
  |  |   68|      8|#define KEYSZ	32
  ------------------
              	_rs_init(rsx->rs_buf, KEYSZ + IVSZ);
  ------------------
  |  |   69|      8|#define IVSZ	8
  ------------------
  164|      8|	memset(rsx->rs_buf, 0, KEYSZ + IVSZ);
  ------------------
  |  |   68|      8|#define KEYSZ	32
  ------------------
              	memset(rsx->rs_buf, 0, KEYSZ + IVSZ);
  ------------------
  |  |   69|      8|#define IVSZ	8
  ------------------
  165|      8|	rs->rs_have = sizeof(rsx->rs_buf) - KEYSZ - IVSZ;
  ------------------
  |  |   68|      8|#define KEYSZ	32
  ------------------
              	rs->rs_have = sizeof(rsx->rs_buf) - KEYSZ - IVSZ;
  ------------------
  |  |   69|      8|#define IVSZ	8
  ------------------
  166|      8|}
arc4random.c:_rs_random_buf:
  170|    815|{
  171|    815|	u_char *buf = (u_char *)_buf;
  172|    815|	u_char *keystream;
  173|    815|	size_t m;
  174|       |
  175|    815|	_rs_stir_if_needed(n);
  176|  1.63k|	while (n > 0) {
  ------------------
  |  Branch (176:9): [True: 821, False: 815]
  ------------------
  177|    821|		if (rs->rs_have > 0) {
  ------------------
  |  Branch (177:7): [True: 820, False: 1]
  ------------------
  178|    820|			m = minimum(n, rs->rs_have);
  ------------------
  |  |   60|    820|#define minimum(a, b) ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (60:24): [True: 814, False: 6]
  |  |  ------------------
  ------------------
  179|    820|			keystream = rsx->rs_buf + sizeof(rsx->rs_buf)
  180|    820|			    - rs->rs_have;
  181|    820|			memcpy(buf, keystream, m);
  182|    820|			memset(keystream, 0, m);
  183|    820|			buf += m;
  184|    820|			n -= m;
  185|    820|			rs->rs_have -= m;
  186|    820|		}
  187|    821|		if (rs->rs_have == 0)
  ------------------
  |  Branch (187:7): [True: 7, False: 814]
  ------------------
  188|      7|			_rs_rekey(NULL, 0);
  189|    821|	}
  190|    815|}

arc4random.c:_rs_forkdetect:
   53|    868|{
   54|    868|	static pid_t _rs_pid = 0;
   55|    868|	pid_t pid = getpid();
   56|       |
   57|    868|	if (_rs_pid == 0 || _rs_pid == 1 || _rs_pid != pid || _rs_forked) {
  ------------------
  |  Branch (57:6): [True: 1, False: 867]
  |  Branch (57:22): [True: 0, False: 867]
  |  Branch (57:38): [True: 0, False: 867]
  |  Branch (57:56): [True: 0, False: 867]
  ------------------
   58|      1|		_rs_pid = pid;
   59|      1|		_rs_forked = 0;
   60|      1|		if (rs)
  ------------------
  |  Branch (60:7): [True: 0, False: 1]
  ------------------
   61|      0|			memset(rs, 0, sizeof(*rs));
   62|      1|	}
   63|    868|}
arc4random.c:_rs_allocate:
   67|      1|{
   68|      1|#if defined(HAVE_MMAP) && defined(MAP_ANON) && defined(MAP_PRIVATE)
   69|      1|	if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE,
  ------------------
  |  Branch (69:6): [True: 0, False: 1]
  ------------------
   70|      1|	    MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
   71|      0|		return (-1);
   72|       |
   73|      1|	if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
  ------------------
  |  Branch (73:6): [True: 0, False: 1]
  ------------------
   74|      1|	    MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
   75|      0|		munmap(*rsp, sizeof(**rsp));
   76|      0|		*rsp = NULL;
   77|      0|		return (-1);
   78|      0|	}
   79|       |#else
   80|       |	if ((*rsp = calloc(1, sizeof(**rsp))) == NULL)
   81|       |		return (-1);
   82|       |	if ((*rsxp = calloc(1, sizeof(**rsxp))) == NULL) {
   83|       |		free(*rsp);
   84|       |		*rsp = NULL;
   85|       |		return (-1);
   86|       |	}
   87|       |#endif /* HAVE_MMAP et al */
   88|       |
   89|      1|	_ARC4_ATFORK(_rs_forkhandler);
   90|      1|	return (0);
   91|      1|}

arc4random_uniform:
   39|     53|{
   40|     53|	uint32_t r, min;
   41|       |
   42|     53|	if (upper_bound < 2)
  ------------------
  |  Branch (42:6): [True: 0, False: 53]
  ------------------
   43|      0|		return 0;
   44|       |
   45|       |	/* 2**32 % x == (2**32 - x) % x */
   46|     53|	min = -upper_bound % upper_bound;
   47|       |
   48|       |	/*
   49|       |	 * This could theoretically loop forever but each retry has
   50|       |	 * p > 0.5 (worst case, usually far better) of selecting a
   51|       |	 * number inside the range we need, so it should rarely need
   52|       |	 * to re-roll.
   53|       |	 */
   54|     53|	for (;;) {
   55|     53|		r = arc4random();
   56|     53|		if (r >= min)
  ------------------
  |  Branch (56:7): [True: 53, False: 0]
  ------------------
   57|     53|			break;
   58|     53|	}
   59|       |
   60|     53|	return r % upper_bound;
   61|     53|}

__b64_pton:
  197|      2|{
  198|      2|	u_int tarindex, state;
  199|      2|	int ch;
  200|      2|	char *pos;
  201|       |
  202|      2|	state = 0;
  203|      2|	tarindex = 0;
  204|       |
  205|    382|	while ((ch = *src++) != '\0') {
  ------------------
  |  Branch (205:9): [True: 380, False: 2]
  ------------------
  206|    380|		if (isspace(ch))	/* Skip whitespace anywhere. */
  ------------------
  |  Branch (206:7): [True: 0, False: 380]
  ------------------
  207|      0|			continue;
  208|       |
  209|    380|		if (ch == Pad64)
  ------------------
  |  Branch (209:7): [True: 0, False: 380]
  ------------------
  210|      0|			break;
  211|       |
  212|    380|		pos = strchr(Base64, ch);
  213|    380|		if (pos == 0)		/* A non-base64 character. */
  ------------------
  |  Branch (213:7): [True: 0, False: 380]
  ------------------
  214|      0|			return (-1);
  215|       |
  216|    380|		switch (state) {
  ------------------
  |  Branch (216:11): [True: 380, False: 0]
  ------------------
  217|     95|		case 0:
  ------------------
  |  Branch (217:3): [True: 95, False: 285]
  ------------------
  218|     95|			if (target) {
  ------------------
  |  Branch (218:8): [True: 95, False: 0]
  ------------------
  219|     95|				if (tarindex >= targsize)
  ------------------
  |  Branch (219:9): [True: 0, False: 95]
  ------------------
  220|      0|					return (-1);
  221|     95|				target[tarindex] = (pos - Base64) << 2;
  222|     95|			}
  223|     95|			state = 1;
  224|     95|			break;
  225|     95|		case 1:
  ------------------
  |  Branch (225:3): [True: 95, False: 285]
  ------------------
  226|     95|			if (target) {
  ------------------
  |  Branch (226:8): [True: 95, False: 0]
  ------------------
  227|     95|				if (tarindex + 1 >= targsize)
  ------------------
  |  Branch (227:9): [True: 0, False: 95]
  ------------------
  228|      0|					return (-1);
  229|     95|				target[tarindex]   |=  (pos - Base64) >> 4;
  230|     95|				target[tarindex+1]  = ((pos - Base64) & 0x0f)
  231|     95|							<< 4 ;
  232|     95|			}
  233|     95|			tarindex++;
  234|     95|			state = 2;
  235|     95|			break;
  236|     95|		case 2:
  ------------------
  |  Branch (236:3): [True: 95, False: 285]
  ------------------
  237|     95|			if (target) {
  ------------------
  |  Branch (237:8): [True: 95, False: 0]
  ------------------
  238|     95|				if (tarindex + 1 >= targsize)
  ------------------
  |  Branch (238:9): [True: 0, False: 95]
  ------------------
  239|      0|					return (-1);
  240|     95|				target[tarindex]   |=  (pos - Base64) >> 2;
  241|     95|				target[tarindex+1]  = ((pos - Base64) & 0x03)
  242|     95|							<< 6;
  243|     95|			}
  244|     95|			tarindex++;
  245|     95|			state = 3;
  246|     95|			break;
  247|     95|		case 3:
  ------------------
  |  Branch (247:3): [True: 95, False: 285]
  ------------------
  248|     95|			if (target) {
  ------------------
  |  Branch (248:8): [True: 95, False: 0]
  ------------------
  249|     95|				if (tarindex >= targsize)
  ------------------
  |  Branch (249:9): [True: 0, False: 95]
  ------------------
  250|      0|					return (-1);
  251|     95|				target[tarindex] |= (pos - Base64);
  252|     95|			}
  253|     95|			tarindex++;
  254|     95|			state = 0;
  255|     95|			break;
  256|    380|		}
  257|    380|	}
  258|       |
  259|       |	/*
  260|       |	 * We are done decoding Base-64 chars.  Let's see if we ended
  261|       |	 * on a byte boundary, and/or with erroneous trailing characters.
  262|       |	 */
  263|       |
  264|      2|	if (ch == Pad64) {		/* We got a pad char. */
  ------------------
  |  Branch (264:6): [True: 0, False: 2]
  ------------------
  265|      0|		ch = *src++;		/* Skip it, get next. */
  266|      0|		switch (state) {
  ------------------
  |  Branch (266:11): [True: 0, False: 0]
  ------------------
  267|      0|		case 0:		/* Invalid = in first position */
  ------------------
  |  Branch (267:3): [True: 0, False: 0]
  ------------------
  268|      0|		case 1:		/* Invalid = in second position */
  ------------------
  |  Branch (268:3): [True: 0, False: 0]
  ------------------
  269|      0|			return (-1);
  270|       |
  271|      0|		case 2:		/* Valid, means one byte of info */
  ------------------
  |  Branch (271:3): [True: 0, False: 0]
  ------------------
  272|       |			/* Skip any number of spaces. */
  273|      0|			for (; ch != '\0'; ch = *src++)
  ------------------
  |  Branch (273:11): [True: 0, False: 0]
  ------------------
  274|      0|				if (!isspace(ch))
  ------------------
  |  Branch (274:9): [True: 0, False: 0]
  ------------------
  275|      0|					break;
  276|       |			/* Make sure there is another trailing = sign. */
  277|      0|			if (ch != Pad64)
  ------------------
  |  Branch (277:8): [True: 0, False: 0]
  ------------------
  278|      0|				return (-1);
  279|      0|			ch = *src++;		/* Skip the = */
  280|       |			/* Fall through to "single trailing =" case. */
  281|       |			/* FALLTHROUGH */
  282|       |
  283|      0|		case 3:		/* Valid, means two bytes of info */
  ------------------
  |  Branch (283:3): [True: 0, False: 0]
  ------------------
  284|       |			/*
  285|       |			 * We know this char is an =.  Is there anything but
  286|       |			 * whitespace after it?
  287|       |			 */
  288|      0|			for (; ch != '\0'; ch = *src++)
  ------------------
  |  Branch (288:11): [True: 0, False: 0]
  ------------------
  289|      0|				if (!isspace(ch))
  ------------------
  |  Branch (289:9): [True: 0, False: 0]
  ------------------
  290|      0|					return (-1);
  291|       |
  292|       |			/*
  293|       |			 * Now make sure for cases 2 and 3 that the "extra"
  294|       |			 * bits that slopped past the last full byte were
  295|       |			 * zeros.  If we don't check them, they become a
  296|       |			 * subliminal channel.
  297|       |			 */
  298|      0|			if (target && target[tarindex] != 0)
  ------------------
  |  Branch (298:8): [True: 0, False: 0]
  |  Branch (298:18): [True: 0, False: 0]
  ------------------
  299|      0|				return (-1);
  300|      0|		}
  301|      2|	} else {
  302|       |		/*
  303|       |		 * We ended by seeing the end of the string.  Make sure we
  304|       |		 * have no partial bytes lying around.
  305|       |		 */
  306|      2|		if (state != 0)
  ------------------
  |  Branch (306:7): [True: 0, False: 2]
  ------------------
  307|      0|			return (-1);
  308|      2|	}
  309|       |
  310|      2|	return (tarindex);
  311|      2|}

_ssh_compat_getentropy:
   43|      1|{
   44|      1|#if defined(WITH_OPENSSL) && defined(OPENSSL_PRNG_ONLY)
   45|      1|	if (RAND_bytes(s, len) <= 0)
  ------------------
  |  Branch (45:6): [True: 0, False: 1]
  ------------------
   46|      0|		fatal("Couldn't obtain random bytes (error 0x%lx)",
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
   47|      1|		    (unsigned long)ERR_get_error());
   48|       |#else
   49|       |	int fd, save_errno;
   50|       |	ssize_t r;
   51|       |	size_t o = 0;
   52|       |
   53|       |#ifdef WITH_OPENSSL
   54|       |	if (RAND_bytes(s, len) == 1)
   55|       |		return 0;
   56|       |#endif
   57|       |#ifdef HAVE_GETENTROPY
   58|       |	if ((r = getentropy(s, len)) == 0)
   59|       |		return 0;
   60|       |#endif /* HAVE_GETENTROPY */
   61|       |#ifdef HAVE_GETRANDOM
   62|       |	if ((r = getrandom(s, len, 0)) > 0 && (size_t)r == len)
   63|       |		return 0;
   64|       |#endif /* HAVE_GETRANDOM */
   65|       |
   66|       |	if ((fd = open(SSH_RANDOM_DEV, O_RDONLY)) == -1) {
   67|       |		save_errno = errno;
   68|       |		/* Try egd/prngd before giving up. */
   69|       |		if (seed_from_prngd(s, len) == 0)
   70|       |			return 0;
   71|       |		fatal("Couldn't open %s: %s", SSH_RANDOM_DEV,
   72|       |		    strerror(save_errno));
   73|       |	}
   74|       |	while (o < len) {
   75|       |		r = read(fd, (u_char *)s + o, len - o);
   76|       |		if (r < 0) {
   77|       |			if (errno == EAGAIN || errno == EINTR ||
   78|       |			    errno == EWOULDBLOCK)
   79|       |				continue;
   80|       |			fatal("read %s: %s", SSH_RANDOM_DEV, strerror(errno));
   81|       |		}
   82|       |		o += r;
   83|       |	}
   84|       |	close(fd);
   85|       |#endif /* WITH_OPENSSL */
   86|      1|	return 0;
   87|      1|}

arc4random.c:chacha_keysetup:
   58|      9|{
   59|      9|  const char *constants;
   60|       |
   61|      9|  x->input[4] = U8TO32_LITTLE(k + 0);
  ------------------
  |  |   29|      9|  (((u32)((p)[0])      ) | \
  |  |   30|      9|   ((u32)((p)[1]) <<  8) | \
  |  |   31|      9|   ((u32)((p)[2]) << 16) | \
  |  |   32|      9|   ((u32)((p)[3]) << 24))
  ------------------
   62|      9|  x->input[5] = U8TO32_LITTLE(k + 4);
  ------------------
  |  |   29|      9|  (((u32)((p)[0])      ) | \
  |  |   30|      9|   ((u32)((p)[1]) <<  8) | \
  |  |   31|      9|   ((u32)((p)[2]) << 16) | \
  |  |   32|      9|   ((u32)((p)[3]) << 24))
  ------------------
   63|      9|  x->input[6] = U8TO32_LITTLE(k + 8);
  ------------------
  |  |   29|      9|  (((u32)((p)[0])      ) | \
  |  |   30|      9|   ((u32)((p)[1]) <<  8) | \
  |  |   31|      9|   ((u32)((p)[2]) << 16) | \
  |  |   32|      9|   ((u32)((p)[3]) << 24))
  ------------------
   64|      9|  x->input[7] = U8TO32_LITTLE(k + 12);
  ------------------
  |  |   29|      9|  (((u32)((p)[0])      ) | \
  |  |   30|      9|   ((u32)((p)[1]) <<  8) | \
  |  |   31|      9|   ((u32)((p)[2]) << 16) | \
  |  |   32|      9|   ((u32)((p)[3]) << 24))
  ------------------
   65|      9|  if (kbits == 256) { /* recommended */
  ------------------
  |  Branch (65:7): [True: 9, False: 0]
  ------------------
   66|      9|    k += 16;
   67|      9|    constants = sigma;
   68|      9|  } else { /* kbits == 128 */
   69|      0|    constants = tau;
   70|      0|  }
   71|      9|  x->input[8] = U8TO32_LITTLE(k + 0);
  ------------------
  |  |   29|      9|  (((u32)((p)[0])      ) | \
  |  |   30|      9|   ((u32)((p)[1]) <<  8) | \
  |  |   31|      9|   ((u32)((p)[2]) << 16) | \
  |  |   32|      9|   ((u32)((p)[3]) << 24))
  ------------------
   72|      9|  x->input[9] = U8TO32_LITTLE(k + 4);
  ------------------
  |  |   29|      9|  (((u32)((p)[0])      ) | \
  |  |   30|      9|   ((u32)((p)[1]) <<  8) | \
  |  |   31|      9|   ((u32)((p)[2]) << 16) | \
  |  |   32|      9|   ((u32)((p)[3]) << 24))
  ------------------
   73|      9|  x->input[10] = U8TO32_LITTLE(k + 8);
  ------------------
  |  |   29|      9|  (((u32)((p)[0])      ) | \
  |  |   30|      9|   ((u32)((p)[1]) <<  8) | \
  |  |   31|      9|   ((u32)((p)[2]) << 16) | \
  |  |   32|      9|   ((u32)((p)[3]) << 24))
  ------------------
   74|      9|  x->input[11] = U8TO32_LITTLE(k + 12);
  ------------------
  |  |   29|      9|  (((u32)((p)[0])      ) | \
  |  |   30|      9|   ((u32)((p)[1]) <<  8) | \
  |  |   31|      9|   ((u32)((p)[2]) << 16) | \
  |  |   32|      9|   ((u32)((p)[3]) << 24))
  ------------------
   75|      9|  x->input[0] = U8TO32_LITTLE(constants + 0);
  ------------------
  |  |   29|      9|  (((u32)((p)[0])      ) | \
  |  |   30|      9|   ((u32)((p)[1]) <<  8) | \
  |  |   31|      9|   ((u32)((p)[2]) << 16) | \
  |  |   32|      9|   ((u32)((p)[3]) << 24))
  ------------------
   76|      9|  x->input[1] = U8TO32_LITTLE(constants + 4);
  ------------------
  |  |   29|      9|  (((u32)((p)[0])      ) | \
  |  |   30|      9|   ((u32)((p)[1]) <<  8) | \
  |  |   31|      9|   ((u32)((p)[2]) << 16) | \
  |  |   32|      9|   ((u32)((p)[3]) << 24))
  ------------------
   77|      9|  x->input[2] = U8TO32_LITTLE(constants + 8);
  ------------------
  |  |   29|      9|  (((u32)((p)[0])      ) | \
  |  |   30|      9|   ((u32)((p)[1]) <<  8) | \
  |  |   31|      9|   ((u32)((p)[2]) << 16) | \
  |  |   32|      9|   ((u32)((p)[3]) << 24))
  ------------------
   78|      9|  x->input[3] = U8TO32_LITTLE(constants + 12);
  ------------------
  |  |   29|      9|  (((u32)((p)[0])      ) | \
  |  |   30|      9|   ((u32)((p)[1]) <<  8) | \
  |  |   31|      9|   ((u32)((p)[2]) << 16) | \
  |  |   32|      9|   ((u32)((p)[3]) << 24))
  ------------------
   79|      9|}
arc4random.c:chacha_ivsetup:
   83|      9|{
   84|      9|  x->input[12] = 0;
   85|      9|  x->input[13] = 0;
   86|      9|  x->input[14] = U8TO32_LITTLE(iv + 0);
  ------------------
  |  |   29|      9|  (((u32)((p)[0])      ) | \
  |  |   30|      9|   ((u32)((p)[1]) <<  8) | \
  |  |   31|      9|   ((u32)((p)[2]) << 16) | \
  |  |   32|      9|   ((u32)((p)[3]) << 24))
  ------------------
   87|      9|  x->input[15] = U8TO32_LITTLE(iv + 4);
  ------------------
  |  |   29|      9|  (((u32)((p)[0])      ) | \
  |  |   30|      9|   ((u32)((p)[1]) <<  8) | \
  |  |   31|      9|   ((u32)((p)[2]) << 16) | \
  |  |   32|      9|   ((u32)((p)[3]) << 24))
  ------------------
   88|      9|}
arc4random.c:chacha_encrypt_bytes:
   92|      9|{
   93|      9|  u32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
   94|      9|  u32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
   95|      9|  u8 *ctarget = NULL;
   96|      9|  u8 tmp[64];
   97|      9|  u_int i;
   98|       |
   99|      9|  if (!bytes) return;
  ------------------
  |  Branch (99:7): [True: 0, False: 9]
  ------------------
  100|       |
  101|      9|  j0 = x->input[0];
  102|      9|  j1 = x->input[1];
  103|      9|  j2 = x->input[2];
  104|      9|  j3 = x->input[3];
  105|      9|  j4 = x->input[4];
  106|      9|  j5 = x->input[5];
  107|      9|  j6 = x->input[6];
  108|      9|  j7 = x->input[7];
  109|      9|  j8 = x->input[8];
  110|      9|  j9 = x->input[9];
  111|      9|  j10 = x->input[10];
  112|      9|  j11 = x->input[11];
  113|      9|  j12 = x->input[12];
  114|      9|  j13 = x->input[13];
  115|      9|  j14 = x->input[14];
  116|      9|  j15 = x->input[15];
  117|       |
  118|    129|  for (;;) {
  119|    129|    if (bytes < 64) {
  ------------------
  |  Branch (119:9): [True: 1, False: 128]
  ------------------
  120|      5|      for (i = 0;i < bytes;++i) tmp[i] = m[i];
  ------------------
  |  Branch (120:18): [True: 4, False: 1]
  ------------------
  121|      1|      m = tmp;
  122|      1|      ctarget = c;
  123|      1|      c = tmp;
  124|      1|    }
  125|    129|    x0 = j0;
  126|    129|    x1 = j1;
  127|    129|    x2 = j2;
  128|    129|    x3 = j3;
  129|    129|    x4 = j4;
  130|    129|    x5 = j5;
  131|    129|    x6 = j6;
  132|    129|    x7 = j7;
  133|    129|    x8 = j8;
  134|    129|    x9 = j9;
  135|    129|    x10 = j10;
  136|    129|    x11 = j11;
  137|    129|    x12 = j12;
  138|    129|    x13 = j13;
  139|    129|    x14 = j14;
  140|    129|    x15 = j15;
  141|  1.41k|    for (i = 20;i > 0;i -= 2) {
  ------------------
  |  Branch (141:17): [True: 1.29k, False: 129]
  ------------------
  142|  1.29k|      QUARTERROUND( x0, x4, x8,x12)
  ------------------
  |  |   48|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   49|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   51|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  143|  1.29k|      QUARTERROUND( x1, x5, x9,x13)
  ------------------
  |  |   48|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   49|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   51|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|  1.29k|      QUARTERROUND( x2, x6,x10,x14)
  ------------------
  |  |   48|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   49|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   51|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  145|  1.29k|      QUARTERROUND( x3, x7,x11,x15)
  ------------------
  |  |   48|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   49|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   51|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  146|  1.29k|      QUARTERROUND( x0, x5,x10,x15)
  ------------------
  |  |   48|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   49|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   51|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  147|  1.29k|      QUARTERROUND( x1, x6,x11,x12)
  ------------------
  |  |   48|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   49|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   51|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  148|  1.29k|      QUARTERROUND( x2, x7, x8,x13)
  ------------------
  |  |   48|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   49|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   51|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  149|  1.29k|      QUARTERROUND( x3, x4, x9,x14)
  ------------------
  |  |   48|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   49|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  1.29k|  a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   51|  1.29k|  c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   44|  1.29k|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
  |  |  ------------------
  |  |  |  |   42|  1.29k|#define ROTATE(v,c) (ROTL32(v,c))
  |  |  |  |  ------------------
  |  |  |  |  |  |   26|  1.29k|  (U32V((v) << (n)) | ((v) >> (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|  1.29k|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   20|  1.29k|#define U32C(v) (v##U)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  150|  1.29k|    }
  151|    129|    x0 = PLUS(x0,j0);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  152|    129|    x1 = PLUS(x1,j1);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  153|    129|    x2 = PLUS(x2,j2);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  154|    129|    x3 = PLUS(x3,j3);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  155|    129|    x4 = PLUS(x4,j4);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  156|    129|    x5 = PLUS(x5,j5);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  157|    129|    x6 = PLUS(x6,j6);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  158|    129|    x7 = PLUS(x7,j7);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  159|    129|    x8 = PLUS(x8,j8);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  160|    129|    x9 = PLUS(x9,j9);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  161|    129|    x10 = PLUS(x10,j10);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|    129|    x11 = PLUS(x11,j11);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  163|    129|    x12 = PLUS(x12,j12);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  164|    129|    x13 = PLUS(x13,j13);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  165|    129|    x14 = PLUS(x14,j14);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  166|    129|    x15 = PLUS(x15,j15);
  ------------------
  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  ------------------
  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  167|       |
  168|       |#ifndef KEYSTREAM_ONLY
  169|       |    x0 = XOR(x0,U8TO32_LITTLE(m + 0));
  170|       |    x1 = XOR(x1,U8TO32_LITTLE(m + 4));
  171|       |    x2 = XOR(x2,U8TO32_LITTLE(m + 8));
  172|       |    x3 = XOR(x3,U8TO32_LITTLE(m + 12));
  173|       |    x4 = XOR(x4,U8TO32_LITTLE(m + 16));
  174|       |    x5 = XOR(x5,U8TO32_LITTLE(m + 20));
  175|       |    x6 = XOR(x6,U8TO32_LITTLE(m + 24));
  176|       |    x7 = XOR(x7,U8TO32_LITTLE(m + 28));
  177|       |    x8 = XOR(x8,U8TO32_LITTLE(m + 32));
  178|       |    x9 = XOR(x9,U8TO32_LITTLE(m + 36));
  179|       |    x10 = XOR(x10,U8TO32_LITTLE(m + 40));
  180|       |    x11 = XOR(x11,U8TO32_LITTLE(m + 44));
  181|       |    x12 = XOR(x12,U8TO32_LITTLE(m + 48));
  182|       |    x13 = XOR(x13,U8TO32_LITTLE(m + 52));
  183|       |    x14 = XOR(x14,U8TO32_LITTLE(m + 56));
  184|       |    x15 = XOR(x15,U8TO32_LITTLE(m + 60));
  185|       |#endif
  186|       |
  187|    129|    j12 = PLUSONE(j12);
  ------------------
  |  |   45|    129|#define PLUSONE(v) (PLUS((v),1))
  |  |  ------------------
  |  |  |  |   44|    129|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|    129|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|    129|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  188|    129|    if (!j12) {
  ------------------
  |  Branch (188:9): [True: 0, False: 129]
  ------------------
  189|      0|      j13 = PLUSONE(j13);
  ------------------
  |  |   45|      0|#define PLUSONE(v) (PLUS((v),1))
  |  |  ------------------
  |  |  |  |   44|      0|#define PLUS(v,w) (U32V((v) + (w)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|      0|#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|      0|#define U32C(v) (v##U)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  190|       |      /* stopping at 2^70 bytes per nonce is user's responsibility */
  191|      0|    }
  192|       |
  193|    129|    U32TO8_LITTLE(c + 0,x0);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  194|    129|    U32TO8_LITTLE(c + 4,x1);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  195|    129|    U32TO8_LITTLE(c + 8,x2);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  196|    129|    U32TO8_LITTLE(c + 12,x3);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  197|    129|    U32TO8_LITTLE(c + 16,x4);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  198|    129|    U32TO8_LITTLE(c + 20,x5);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  199|    129|    U32TO8_LITTLE(c + 24,x6);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  200|    129|    U32TO8_LITTLE(c + 28,x7);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  201|    129|    U32TO8_LITTLE(c + 32,x8);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  202|    129|    U32TO8_LITTLE(c + 36,x9);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  203|    129|    U32TO8_LITTLE(c + 40,x10);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  204|    129|    U32TO8_LITTLE(c + 44,x11);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  205|    129|    U32TO8_LITTLE(c + 48,x12);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  206|    129|    U32TO8_LITTLE(c + 52,x13);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  207|    129|    U32TO8_LITTLE(c + 56,x14);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  208|    129|    U32TO8_LITTLE(c + 60,x15);
  ------------------
  |  |   35|    129|  do { \
  |  |   36|    129|    (p)[0] = U8V((v)      ); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    129|    (p)[1] = U8V((v) >>  8); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    129|    (p)[2] = U8V((v) >> 16); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   39|    129|    (p)[3] = U8V((v) >> 24); \
  |  |  ------------------
  |  |  |  |   22|    129|#define U8V(v) ((u8)(v) & U8C(0xFF))
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    129|#define U8C(v) (v##U)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   40|    129|  } while (0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded, False: 129]
  |  |  ------------------
  ------------------
  209|       |
  210|    129|    if (bytes <= 64) {
  ------------------
  |  Branch (210:9): [True: 9, False: 120]
  ------------------
  211|      9|      if (bytes < 64) {
  ------------------
  |  Branch (211:11): [True: 1, False: 8]
  ------------------
  212|      5|        for (i = 0;i < bytes;++i) ctarget[i] = c[i];
  ------------------
  |  Branch (212:20): [True: 4, False: 1]
  ------------------
  213|      1|      }
  214|      9|      x->input[12] = j12;
  215|      9|      x->input[13] = j13;
  216|      9|      return;
  217|      9|    }
  218|    120|    bytes -= 64;
  219|    120|    c += 64;
  220|       |#ifndef KEYSTREAM_ONLY
  221|       |    m += 64;
  222|       |#endif
  223|    120|  }
  224|      9|}

freezero:
   26|  1.84k|{
   27|  1.84k|	if (ptr == NULL)
  ------------------
  |  Branch (27:6): [True: 869, False: 971]
  ------------------
   28|    869|		return;
   29|    971|	explicit_bzero(ptr, sz);
   30|    971|	free(ptr);
   31|    971|}

ssh_compatible_openssl:
   45|      1|{
   46|      1|	long mask, hfix, lfix;
   47|       |
   48|       |	/* exact match is always OK */
   49|      1|	if (headerver == libver)
  ------------------
  |  Branch (49:6): [True: 1, False: 0]
  ------------------
   50|      1|		return 1;
   51|       |
   52|       |	/*
   53|       |	 * For versions >= 3.0, only the major must match.
   54|       |	 */
   55|      0|	if (headerver >= 0x30000000) {
  ------------------
  |  Branch (55:6): [True: 0, False: 0]
  ------------------
   56|      0|		mask = 0xf0000000L; /* major only */
   57|      0|		return (headerver & mask) == (libver & mask);
   58|      0|	}
   59|       |
   60|       |	/*
   61|       |	 * For versions >= 1.0.0, but <3, major,minor,status must match and
   62|       |	 * library fix version must be equal to or newer than the header.
   63|       |	 */
   64|      0|	mask = 0xfff0000fL; /* major,minor,status */
   65|      0|	hfix = (headerver & 0x000ff000) >> 12;
   66|      0|	lfix = (libver & 0x000ff000) >> 12;
   67|      0|	if ( (headerver & mask) == (libver & mask) && lfix >= hfix)
  ------------------
  |  Branch (67:7): [True: 0, False: 0]
  |  Branch (67:48): [True: 0, False: 0]
  ------------------
   68|      0|		return 1;
   69|      0|	return 0;
   70|      0|}
ssh_libcrypto_init:
   74|      1|{
   75|      1|	uint64_t opts = OPENSSL_INIT_ADD_ALL_CIPHERS |
   76|      1|	    OPENSSL_INIT_ADD_ALL_DIGESTS;
   77|       |
   78|       |#ifdef	USE_OPENSSL_ENGINE
   79|       |	/* Enable use of crypto hardware */
   80|       |	ENGINE_load_builtin_engines();
   81|       |	ENGINE_register_all_complete();
   82|       |
   83|       |	/* Tell libcrypto config file to pick up engines defined there */
   84|       |	opts |= OPENSSL_INIT_LOAD_CONFIG;
   85|       |#endif /* USE_OPENSSL_ENGINE */
   86|       |
   87|       |	return OPENSSL_init_crypto(opts, NULL);
   88|      1|}

recallocarray:
   37|    486|{
   38|    486|	size_t oldsize, newsize;
   39|    486|	void *newptr;
   40|       |
   41|    486|	if (ptr == NULL)
  ------------------
  |  Branch (41:6): [True: 4, False: 482]
  ------------------
   42|      4|		return calloc(newnmemb, size);
   43|       |
   44|    482|	if ((newnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
  ------------------
  |  |   33|    964|#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
  ------------------
              	if ((newnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
  ------------------
  |  |   33|    482|#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
  ------------------
  |  Branch (44:7): [True: 0, False: 482]
  |  Branch (44:38): [True: 0, False: 482]
  ------------------
   45|    482|	    newnmemb > 0 && SIZE_MAX / newnmemb < size) {
  ------------------
  |  Branch (45:6): [True: 0, False: 0]
  |  Branch (45:22): [True: 0, False: 0]
  ------------------
   46|      0|		errno = ENOMEM;
   47|      0|		return NULL;
   48|      0|	}
   49|    482|	newsize = newnmemb * size;
   50|       |
   51|    482|	if ((oldnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
  ------------------
  |  |   33|    964|#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
  ------------------
              	if ((oldnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
  ------------------
  |  |   33|    482|#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
  ------------------
  |  Branch (51:7): [True: 0, False: 482]
  |  Branch (51:38): [True: 0, False: 482]
  ------------------
   52|    482|	    oldnmemb > 0 && SIZE_MAX / oldnmemb < size) {
  ------------------
  |  Branch (52:6): [True: 0, False: 0]
  |  Branch (52:22): [True: 0, False: 0]
  ------------------
   53|      0|		errno = EINVAL;
   54|      0|		return NULL;
   55|      0|	}
   56|    482|	oldsize = oldnmemb * size;
   57|       |	
   58|       |	/*
   59|       |	 * Don't bother too much if we're shrinking just a bit,
   60|       |	 * we do not shrink for series of small steps, oh well.
   61|       |	 */
   62|    482|	if (newsize <= oldsize) {
  ------------------
  |  Branch (62:6): [True: 91, False: 391]
  ------------------
   63|     91|		size_t d = oldsize - newsize;
   64|       |
   65|     91|		if (d < oldsize / 2 && d < (size_t)getpagesize()) {
  ------------------
  |  Branch (65:7): [True: 0, False: 91]
  |  Branch (65:26): [True: 0, False: 0]
  ------------------
   66|      0|			memset((char *)ptr + newsize, 0, d);
   67|      0|			return ptr;
   68|      0|		}
   69|     91|	}
   70|       |
   71|    482|	newptr = malloc(newsize);
   72|    482|	if (newptr == NULL)
  ------------------
  |  Branch (72:6): [True: 0, False: 482]
  ------------------
   73|      0|		return NULL;
   74|       |
   75|    482|	if (newsize > oldsize) {
  ------------------
  |  Branch (75:6): [True: 391, False: 91]
  ------------------
   76|    391|		memcpy(newptr, ptr, oldsize);
   77|    391|		memset((char *)newptr + oldsize, 0, newsize - oldsize);
   78|    391|	} else
   79|     91|		memcpy(newptr, ptr, newsize);
   80|       |
   81|    482|	explicit_bzero(ptr, oldsize);
   82|    482|	free(ptr);
   83|       |
   84|    482|	return newptr;
   85|    482|}

setproctitle:
  125|    331|{
  126|    331|#if SPT_TYPE != SPT_NONE
  127|    331|	va_list ap;
  128|    331|	char buf[1024], ptitle[1024];
  129|    331|	size_t len = 0;
  130|    331|	int r;
  131|    331|	extern char *__progname;
  132|       |#if SPT_TYPE == SPT_PSTAT
  133|       |	union pstun pst;
  134|       |#endif
  135|       |
  136|    331|#if SPT_TYPE == SPT_REUSEARGV
  137|    331|	if (argv_env_len <= 0)
  ------------------
  |  Branch (137:6): [True: 331, False: 0]
  ------------------
  138|    331|		return;
  139|      0|#endif
  140|       |
  141|      0|	strlcpy(buf, __progname, sizeof(buf));
  142|       |
  143|      0|	r = -1;
  144|      0|	va_start(ap, fmt);
  145|      0|	if (fmt != NULL) {
  ------------------
  |  Branch (145:6): [True: 0, False: 0]
  ------------------
  146|      0|		len = strlcat(buf, ": ", sizeof(buf));
  147|      0|		if (len < sizeof(buf))
  ------------------
  |  Branch (147:7): [True: 0, False: 0]
  ------------------
  148|      0|			r = vsnprintf(buf + len, sizeof(buf) - len , fmt, ap);
  149|      0|	}
  150|      0|	va_end(ap);
  151|      0|	if (r == -1 || (size_t)r >= sizeof(buf) - len)
  ------------------
  |  Branch (151:6): [True: 0, False: 0]
  |  Branch (151:17): [True: 0, False: 0]
  ------------------
  152|      0|		return;
  153|      0|	strnvis(ptitle, buf, sizeof(ptitle),
  154|      0|	    VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL);
  ------------------
  |  |   50|      0|#define	VIS_CSTYLE	0x02	/* use \[nrft0..] where appropriate */
  ------------------
              	    VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL);
  ------------------
  |  |   58|      0|#define	VIS_NL		0x10	/* also encode newline */
  ------------------
              	    VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL);
  ------------------
  |  |   57|      0|#define	VIS_TAB		0x08	/* also encode tab */
  ------------------
              	    VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL);
  ------------------
  |  |   49|      0|#define	VIS_OCTAL	0x01	/* use octal \ddd format */
  ------------------
  155|       |
  156|       |#if SPT_TYPE == SPT_PSTAT
  157|       |	pst.pst_command = ptitle;
  158|       |	pstat(PSTAT_SETCMD, pst, strlen(ptitle), 0, 0);
  159|       |#elif SPT_TYPE == SPT_REUSEARGV
  160|       |/*	debug("setproctitle: copy \"%s\" into len %d",
  161|       |	    buf, argv_env_len); */
  162|      0|	len = strlcpy(argv_start, ptitle, argv_env_len);
  163|      0|	for(; len < argv_env_len; len++)
  ------------------
  |  Branch (163:8): [True: 0, False: 0]
  ------------------
  164|      0|		argv_start[len] = SPT_PADCHAR;
  ------------------
  |  |   58|      0|# define SPT_PADCHAR	'\0'
  ------------------
  165|      0|#endif
  166|       |
  167|      0|#endif /* SPT_NONE */
  168|      0|}

strlcat:
   36|    115|{
   37|    115|	char *d = dst;
   38|    115|	const char *s = src;
   39|    115|	size_t n = siz;
   40|    115|	size_t dlen;
   41|       |
   42|       |	/* Find the end of dst and adjust bytes left but don't go past end */
   43|  19.6k|	while (n-- != 0 && *d != '\0')
  ------------------
  |  Branch (43:9): [True: 19.6k, False: 0]
  |  Branch (43:21): [True: 19.5k, False: 115]
  ------------------
   44|  19.5k|		d++;
   45|    115|	dlen = d - dst;
   46|    115|	n = siz - dlen;
   47|       |
   48|    115|	if (n == 0)
  ------------------
  |  Branch (48:6): [True: 0, False: 115]
  ------------------
   49|      0|		return(dlen + strlen(s));
   50|  1.58k|	while (*s != '\0') {
  ------------------
  |  Branch (50:9): [True: 1.46k, False: 115]
  ------------------
   51|  1.46k|		if (n != 1) {
  ------------------
  |  Branch (51:7): [True: 1.46k, False: 0]
  ------------------
   52|  1.46k|			*d++ = *s;
   53|  1.46k|			n--;
   54|  1.46k|		}
   55|  1.46k|		s++;
   56|  1.46k|	}
   57|    115|	*d = '\0';
   58|       |
   59|    115|	return(dlen + (s - src));	/* count does not include NUL */
   60|    115|}

strlcpy:
   34|     38|{
   35|     38|	char *d = dst;
   36|     38|	const char *s = src;
   37|     38|	size_t n = siz;
   38|       |
   39|       |	/* Copy as many bytes as will fit */
   40|     38|	if (n != 0) {
  ------------------
  |  Branch (40:6): [True: 38, False: 0]
  ------------------
   41|  2.27k|		while (--n != 0) {
  ------------------
  |  Branch (41:10): [True: 2.27k, False: 0]
  ------------------
   42|  2.27k|			if ((*d++ = *s++) == '\0')
  ------------------
  |  Branch (42:8): [True: 38, False: 2.23k]
  ------------------
   43|     38|				break;
   44|  2.27k|		}
   45|     38|	}
   46|       |
   47|       |	/* Not enough room in dst, add NUL and traverse rest of src */
   48|     38|	if (n == 0) {
  ------------------
  |  Branch (48:6): [True: 0, False: 38]
  ------------------
   49|      0|		if (siz != 0)
  ------------------
  |  Branch (49:7): [True: 0, False: 0]
  ------------------
   50|      0|			*d = '\0';		/* NUL-terminate dst */
   51|      0|		while (*s++)
  ------------------
  |  Branch (51:10): [True: 0, False: 0]
  ------------------
   52|      0|			;
   53|      0|	}
   54|       |
   55|     38|	return(s - src - 1);	/* count does not include NUL */
   56|     38|}

timingsafe_bcmp:
   25|    410|{
   26|    410|	const unsigned char *p1 = b1, *p2 = b2;
   27|    410|	int ret = 0;
   28|       |
   29|  13.5k|	for (; n > 0; n--)
  ------------------
  |  Branch (29:9): [True: 13.1k, False: 410]
  ------------------
   30|  13.1k|		ret |= *p1++ ^ *p2++;
   31|    410|	return (ret != 0);
   32|    410|}

strnvis:
  175|     36|{
  176|     36|	char *start, *end;
  177|     36|	char tbuf[5];
  178|     36|	int c, i;
  179|       |
  180|     36|	i = 0;
  181|  2.23k|	for (start = dst, end = start + siz - 1; (c = *src) && dst < end; ) {
  ------------------
  |  Branch (181:43): [True: 2.20k, False: 36]
  |  Branch (181:57): [True: 2.20k, False: 0]
  ------------------
  182|  2.20k|		if (isvisible(c, flag)) {
  ------------------
  |  |   47|  2.20k|	(((c) == '\\' || (flag & VIS_ALL) == 0) &&			\
  |  |  ------------------
  |  |  |  |   62|  2.20k|#define	VIS_ALL		0x400	/* encode all characters */
  |  |  ------------------
  |  |  |  Branch (47:4): [True: 0, False: 2.20k]
  |  |  |  Branch (47:19): [True: 2.20k, False: 0]
  |  |  ------------------
  |  |   48|  2.20k|	(((u_int)(c) <= UCHAR_MAX && isascii((u_char)(c)) &&		\
  |  |  ------------------
  |  |  |  Branch (48:4): [True: 2.20k, False: 0]
  |  |  ------------------
  |  |   49|  2.20k|	(((c) != '*' && (c) != '?' && (c) != '[' && (c) != '#') ||	\
  |  |  ------------------
  |  |  |  Branch (49:4): [True: 2.20k, False: 0]
  |  |  |  Branch (49:18): [True: 2.20k, False: 0]
  |  |  |  Branch (49:32): [True: 2.20k, False: 0]
  |  |  |  Branch (49:46): [True: 2.20k, False: 0]
  |  |  ------------------
  |  |   50|  2.20k|		(flag & VIS_GLOB) == 0) && isgraph((u_char)(c))) ||	\
  |  |  ------------------
  |  |  |  |   68|      0|#define	VIS_GLOB	0x100	/* encode glob(3) magics and '#' */
  |  |  ------------------
  |  |  |  Branch (50:3): [True: 0, False: 0]
  |  |  ------------------
  |  |   51|  2.20k|	((flag & VIS_SP) == 0 && (c) == ' ') ||				\
  |  |  ------------------
  |  |  |  |   56|    218|#define	VIS_SP		0x04	/* also encode space */
  |  |  ------------------
  |  |  |  Branch (51:3): [True: 218, False: 0]
  |  |  |  Branch (51:27): [True: 218, False: 0]
  |  |  ------------------
  |  |   52|  2.20k|	((flag & VIS_TAB) == 0 && (c) == '\t') ||			\
  |  |  ------------------
  |  |  |  |   57|      0|#define	VIS_TAB		0x08	/* also encode tab */
  |  |  ------------------
  |  |  |  Branch (52:3): [True: 0, False: 0]
  |  |  |  Branch (52:28): [True: 0, False: 0]
  |  |  ------------------
  |  |   53|  2.20k|	((flag & VIS_NL) == 0 && (c) == '\n') ||			\
  |  |  ------------------
  |  |  |  |   58|      0|#define	VIS_NL		0x10	/* also encode newline */
  |  |  ------------------
  |  |  |  Branch (53:3): [True: 0, False: 0]
  |  |  |  Branch (53:27): [True: 0, False: 0]
  |  |  ------------------
  |  |   54|  2.20k|	((flag & VIS_SAFE) && ((c) == '\b' ||				\
  |  |  ------------------
  |  |  |  |   60|      0|#define	VIS_SAFE	0x20	/* only encode "unsafe" characters */
  |  |  ------------------
  |  |  |  Branch (54:3): [True: 0, False: 0]
  |  |  |  Branch (54:25): [True: 0, False: 0]
  |  |  ------------------
  |  |   55|      0|		(c) == '\007' || (c) == '\r' ||				\
  |  |  ------------------
  |  |  |  Branch (55:3): [True: 0, False: 0]
  |  |  |  Branch (55:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   56|      0|		isgraph((u_char)(c))))))
  ------------------
  |  Branch (182:7): [True: 2.20k, False: 0]
  |  Branch (182:7): [True: 1.98k, False: 218]
  |  Branch (182:7): [True: 0, False: 0]
  ------------------
  183|  2.20k|			if ((c == '"' && (flag & VIS_DQ) != 0) ||
  ------------------
  |  |   61|      0|#define	VIS_DQ		0x200	/* backslash-escape double quotes */
  ------------------
  |  Branch (183:9): [True: 0, False: 2.20k]
  |  Branch (183:21): [True: 0, False: 0]
  ------------------
  184|  2.20k|			    (c == '\\' && (flag & VIS_NOSLASH) == 0)) {
  ------------------
  |  |   67|      0|#define	VIS_NOSLASH	0x40	/* inhibit printing '\' */
  ------------------
  |  Branch (184:9): [True: 0, False: 2.20k]
  |  Branch (184:22): [True: 0, False: 0]
  ------------------
  185|       |				/* need space for the extra '\\' */
  186|      0|				if (dst + 1 >= end) {
  ------------------
  |  Branch (186:9): [True: 0, False: 0]
  ------------------
  187|      0|					i = 2;
  188|      0|					break;
  189|      0|				}
  190|      0|				*dst++ = '\\';
  191|      0|			}
  192|  2.20k|			i = 1;
  193|  2.20k|			*dst++ = c;
  194|  2.20k|			src++;
  195|  2.20k|		} else {
  196|      0|			i = vis(tbuf, c, flag, *++src) - tbuf;
  197|      0|			if (dst + i <= end) {
  ------------------
  |  Branch (197:8): [True: 0, False: 0]
  ------------------
  198|      0|				memcpy(dst, tbuf, i);
  199|      0|				dst += i;
  200|      0|			} else {
  201|      0|				src--;
  202|      0|				break;
  203|      0|			}
  204|      0|		}
  205|  2.20k|	}
  206|     36|	if (siz > 0)
  ------------------
  |  Branch (206:6): [True: 36, False: 0]
  ------------------
  207|     36|		*dst = '\0';
  208|     36|	if (dst + i > end) {
  ------------------
  |  Branch (208:6): [True: 0, False: 36]
  ------------------
  209|       |		/* adjust return value for truncation */
  210|      0|		while ((c = *src))
  ------------------
  |  Branch (210:10): [True: 0, False: 0]
  ------------------
  211|      0|			dst += vis(tbuf, c, flag, *++src) - tbuf;
  212|      0|	}
  213|     36|	return (dst - start);
  214|     36|}

ssh_alloc_session_state:
  236|      2|{
  237|      2|	struct ssh *ssh = NULL;
  238|      2|	struct session_state *state = NULL;
  239|       |
  240|      2|	if ((ssh = calloc(1, sizeof(*ssh))) == NULL ||
  ------------------
  |  Branch (240:6): [True: 0, False: 2]
  ------------------
  241|      2|	    (state = calloc(1, sizeof(*state))) == NULL ||
  ------------------
  |  Branch (241:6): [True: 0, False: 2]
  ------------------
  242|      2|	    (ssh->kex = kex_new()) == NULL ||
  ------------------
  |  Branch (242:6): [True: 0, False: 2]
  ------------------
  243|      2|	    (state->input = sshbuf_new()) == NULL ||
  ------------------
  |  Branch (243:6): [True: 0, False: 2]
  ------------------
  244|      2|	    (state->output = sshbuf_new()) == NULL ||
  ------------------
  |  Branch (244:6): [True: 0, False: 2]
  ------------------
  245|      2|	    (state->outgoing_packet = sshbuf_new()) == NULL ||
  ------------------
  |  Branch (245:6): [True: 0, False: 2]
  ------------------
  246|      2|	    (state->incoming_packet = sshbuf_new()) == NULL)
  ------------------
  |  Branch (246:6): [True: 0, False: 2]
  ------------------
  247|      0|		goto fail;
  248|      2|	TAILQ_INIT(&state->outgoing);
  ------------------
  |  |  557|      2|#define	TAILQ_INIT(head) do {						\
  |  |  558|      2|	(head)->tqh_first = NULL;					\
  |  |  559|      2|	(head)->tqh_last = &(head)->tqh_first;				\
  |  |  560|      2|} while (0)
  |  |  ------------------
  |  |  |  Branch (560:10): [Folded, False: 2]
  |  |  ------------------
  ------------------
  249|      2|	TAILQ_INIT(&ssh->private_keys);
  ------------------
  |  |  557|      2|#define	TAILQ_INIT(head) do {						\
  |  |  558|      2|	(head)->tqh_first = NULL;					\
  |  |  559|      2|	(head)->tqh_last = &(head)->tqh_first;				\
  |  |  560|      2|} while (0)
  |  |  ------------------
  |  |  |  Branch (560:10): [Folded, False: 2]
  |  |  ------------------
  ------------------
  250|      2|	TAILQ_INIT(&ssh->public_keys);
  ------------------
  |  |  557|      2|#define	TAILQ_INIT(head) do {						\
  |  |  558|      2|	(head)->tqh_first = NULL;					\
  |  |  559|      2|	(head)->tqh_last = &(head)->tqh_first;				\
  |  |  560|      2|} while (0)
  |  |  ------------------
  |  |  |  Branch (560:10): [Folded, False: 2]
  |  |  ------------------
  ------------------
  251|      2|	state->connection_in = -1;
  252|      2|	state->connection_out = -1;
  253|      2|	state->max_packet_size = 32768;
  254|      2|	state->packet_timeout_ms = -1;
  255|      2|	state->interactive_mode = 1;
  256|      2|	state->qos_interactive = state->qos_other = -1;
  257|      2|	state->p_send.packets = state->p_read.packets = 0;
  258|      2|	state->initialized = 1;
  259|       |	/*
  260|       |	 * ssh_packet_send2() needs to queue packets until
  261|       |	 * we've done the initial key exchange.
  262|       |	 */
  263|      2|	state->rekeying = 1;
  264|      2|	ssh->state = state;
  265|      2|	return ssh;
  266|      0| fail:
  267|      0|	if (ssh) {
  ------------------
  |  Branch (267:6): [True: 0, False: 0]
  ------------------
  268|      0|		kex_free(ssh->kex);
  269|      0|		free(ssh);
  270|      0|	}
  271|      0|	if (state) {
  ------------------
  |  Branch (271:6): [True: 0, False: 0]
  ------------------
  272|      0|		sshbuf_free(state->input);
  273|      0|		sshbuf_free(state->output);
  274|      0|		sshbuf_free(state->incoming_packet);
  275|      0|		sshbuf_free(state->outgoing_packet);
  276|      0|		free(state);
  277|      0|	}
  278|       |	return NULL;
  279|      2|}
ssh_packet_set_connection:
  301|      2|{
  302|      2|	struct session_state *state;
  303|      2|	const struct sshcipher *none = cipher_by_name("none");
  304|      2|	int r, wasnull = ssh == NULL;
  305|       |
  306|      2|	if (none == NULL) {
  ------------------
  |  Branch (306:6): [True: 0, False: 2]
  ------------------
  307|      0|		error_f("cannot load cipher 'none'");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  308|      0|		return NULL;
  309|      0|	}
  310|      2|	if (ssh == NULL)
  ------------------
  |  Branch (310:6): [True: 2, False: 0]
  ------------------
  311|      2|		ssh = ssh_alloc_session_state();
  312|      2|	if (ssh == NULL) {
  ------------------
  |  Branch (312:6): [True: 0, False: 2]
  ------------------
  313|      0|		error_f("could not allocate state");
  ------------------
  |  |  125|      0|#define error_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
  314|      0|		return NULL;
  315|      0|	}
  316|      2|	state = ssh->state;
  317|      2|	state->start_time = monotime();
  318|      2|	state->connection_in = fd_in;
  319|      2|	state->connection_out = fd_out;
  320|      2|	if ((r = cipher_init(&state->send_context, none,
  ------------------
  |  Branch (320:6): [True: 0, False: 2]
  ------------------
  321|      2|	    (const u_char *)"", 0, NULL, 0, CIPHER_ENCRYPT)) != 0 ||
  ------------------
  |  |   47|      2|#define CIPHER_ENCRYPT		1
  ------------------
  322|      2|	    (r = cipher_init(&state->receive_context, none,
  ------------------
  |  Branch (322:6): [True: 0, False: 2]
  ------------------
  323|      2|	    (const u_char *)"", 0, NULL, 0, CIPHER_DECRYPT)) != 0) {
  ------------------
  |  |   48|      2|#define CIPHER_DECRYPT		0
  ------------------
  324|      0|		error_fr(r, "cipher_init failed");
  ------------------
  |  |  145|      0|#define error_fr(r, ...)	sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), __VA_ARGS__)
  ------------------
  325|      0|		if (wasnull)
  ------------------
  |  Branch (325:7): [True: 0, False: 0]
  ------------------
  326|      0|			free(ssh); /* XXX need ssh_free_session_state? */
  327|      0|		return NULL;
  328|      0|	}
  329|      2|	state->newkeys[MODE_IN] = state->newkeys[MODE_OUT] = NULL;
  330|       |	/*
  331|       |	 * Cache the IP address of the remote connection for use in error
  332|       |	 * messages that might be generated after the connection has closed.
  333|       |	 */
  334|      2|	(void)ssh_remote_ipaddr(ssh);
  335|      2|	return ssh;
  336|      2|}
ssh_packet_set_log_preamble:
  370|    331|{
  371|    331|	va_list args;
  372|    331|	int r;
  373|       |
  374|    331|	free(ssh->log_preamble);
  375|    331|	if (fmt == NULL)
  ------------------
  |  Branch (375:6): [True: 0, False: 331]
  ------------------
  376|      0|		ssh->log_preamble = NULL;
  377|    331|	else {
  378|    331|		va_start(args, fmt);
  379|    331|		r = vasprintf(&ssh->log_preamble, fmt, args);
  380|    331|		va_end(args);
  381|    331|		if (r < 0 || ssh->log_preamble == NULL)
  ------------------
  |  Branch (381:7): [True: 0, False: 331]
  |  Branch (381:16): [True: 0, False: 331]
  ------------------
  382|      0|			return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  383|    331|	}
  384|    331|	return 0;
  385|    331|}
ssh_packet_connection_is_on_socket:
  444|      2|{
  445|      2|	struct session_state *state;
  446|      2|	struct sockaddr_storage from, to;
  447|      2|	socklen_t fromlen, tolen;
  448|       |
  449|      2|	if (ssh == NULL || ssh->state == NULL)
  ------------------
  |  Branch (449:6): [True: 0, False: 2]
  |  Branch (449:21): [True: 0, False: 2]
  ------------------
  450|      0|		return 0;
  451|       |
  452|      2|	state = ssh->state;
  453|      2|	if (state->connection_in == -1 || state->connection_out == -1)
  ------------------
  |  Branch (453:6): [True: 2, False: 0]
  |  Branch (453:36): [True: 0, False: 0]
  ------------------
  454|      2|		return 0;
  455|      0|	fromlen = sizeof(from);
  456|      0|	memset(&from, 0, sizeof(from));
  457|      0|	if (getpeername(state->connection_in, (struct sockaddr *)&from,
  ------------------
  |  Branch (457:6): [True: 0, False: 0]
  ------------------
  458|      0|	    &fromlen) == -1)
  459|      0|		return 0;
  460|      0|	if (from.ss_family != AF_INET && from.ss_family != AF_INET6)
  ------------------
  |  Branch (460:6): [True: 0, False: 0]
  |  Branch (460:35): [True: 0, False: 0]
  ------------------
  461|      0|		return 0;
  462|       |	/* filedescriptors in and out are the same, so it's a socket */
  463|      0|	if (state->connection_in == state->connection_out)
  ------------------
  |  Branch (463:6): [True: 0, False: 0]
  ------------------
  464|      0|		return 1;
  465|      0|	tolen = sizeof(to);
  466|      0|	memset(&to, 0, sizeof(to));
  467|      0|	if (getpeername(state->connection_out, (struct sockaddr *)&to,
  ------------------
  |  Branch (467:6): [True: 0, False: 0]
  ------------------
  468|      0|	    &tolen) == -1)
  469|      0|		return 0;
  470|      0|	if (fromlen != tolen || memcmp(&from, &to, fromlen) != 0)
  ------------------
  |  Branch (470:6): [True: 0, False: 0]
  |  Branch (470:26): [True: 0, False: 0]
  ------------------
  471|      0|		return 0;
  472|      0|	return 1;
  473|      0|}
ssh_remote_ipaddr:
  525|      2|{
  526|      2|	int sock;
  527|       |
  528|       |	/* Check whether we have cached the ipaddr. */
  529|      2|	if (ssh->remote_ipaddr == NULL) {
  ------------------
  |  Branch (529:6): [True: 2, False: 0]
  ------------------
  530|      2|		if (ssh_packet_connection_is_on_socket(ssh)) {
  ------------------
  |  Branch (530:7): [True: 0, False: 2]
  ------------------
  531|      0|			sock = ssh->state->connection_in;
  532|      0|			ssh->remote_ipaddr = get_peer_ipaddr(sock);
  533|      0|			ssh->remote_port = get_peer_port(sock);
  534|      0|			ssh->local_ipaddr = get_local_ipaddr(sock);
  535|      0|			ssh->local_port = get_local_port(sock);
  536|      2|		} else {
  537|      2|			ssh->remote_ipaddr = xstrdup("UNKNOWN");
  538|      2|			ssh->remote_port = 65535;
  539|      2|			ssh->local_ipaddr = xstrdup("UNKNOWN");
  540|      2|			ssh->local_port = 65535;
  541|      2|		}
  542|      2|	}
  543|      2|	return ssh->remote_ipaddr;
  544|      2|}
ssh_set_newkeys:
  977|      4|{
  978|      4|	struct session_state *state = ssh->state;
  979|      4|	struct sshenc *enc;
  980|      4|	struct sshmac *mac;
  981|      4|	struct sshcomp *comp;
  982|      4|	struct sshcipher_ctx **ccp;
  983|      4|	struct packet_state *ps;
  984|      4|	uint64_t *max_blocks, *hard_max_blocks;
  985|      4|	const char *wmsg;
  986|      4|	int r, crypt_type;
  987|      4|	const char *dir = mode == MODE_OUT ? "out" : "in";
  ------------------
  |  Branch (987:20): [True: 2, False: 2]
  ------------------
  988|       |
  989|      4|	debug2_f("mode %d", mode);
  ------------------
  |  |  121|      4|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  990|       |
  991|      4|	if (mode == MODE_OUT) {
  ------------------
  |  Branch (991:6): [True: 2, False: 2]
  ------------------
  992|      2|		ccp = &state->send_context;
  993|      2|		crypt_type = CIPHER_ENCRYPT;
  ------------------
  |  |   47|      2|#define CIPHER_ENCRYPT		1
  ------------------
  994|      2|		ps = &state->p_send;
  995|      2|		hard_max_blocks = &state->hard_max_blocks_out;
  996|      2|		max_blocks = &state->max_blocks_out;
  997|      2|	} else {
  998|      2|		ccp = &state->receive_context;
  999|      2|		crypt_type = CIPHER_DECRYPT;
  ------------------
  |  |   48|      2|#define CIPHER_DECRYPT		0
  ------------------
 1000|      2|		ps = &state->p_read;
 1001|      2|		hard_max_blocks = &state->hard_max_blocks_in;
 1002|      2|		max_blocks = &state->max_blocks_in;
 1003|      2|	}
 1004|      4|	if (state->newkeys[mode] != NULL) {
  ------------------
  |  Branch (1004:6): [True: 0, False: 4]
  ------------------
 1005|      0|		debug_f("rekeying %s, input %llu bytes %llu blocks, "
  ------------------
  |  |  122|      0|#define debug_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
 1006|      0|		    "output %llu bytes %llu blocks", dir,
 1007|      0|		    (unsigned long long)state->p_read.bytes,
 1008|      0|		    (unsigned long long)state->p_read.blocks,
 1009|      0|		    (unsigned long long)state->p_send.bytes,
 1010|      0|		    (unsigned long long)state->p_send.blocks);
 1011|      0|		kex_free_newkeys(state->newkeys[mode]);
 1012|      0|		state->newkeys[mode] = NULL;
 1013|      0|	}
 1014|       |	/* note that both bytes and the seqnr are not reset */
 1015|      4|	ps->packets = ps->blocks = 0;
 1016|       |	/* move newkeys from kex to state */
 1017|      4|	if ((state->newkeys[mode] = ssh->kex->newkeys[mode]) == NULL)
  ------------------
  |  Branch (1017:6): [True: 0, False: 4]
  ------------------
 1018|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 1019|      4|	ssh->kex->newkeys[mode] = NULL;
 1020|      4|	enc  = &state->newkeys[mode]->enc;
 1021|      4|	mac  = &state->newkeys[mode]->mac;
 1022|      4|	comp = &state->newkeys[mode]->comp;
 1023|      4|	if (cipher_authlen(enc->cipher) == 0) {
  ------------------
  |  Branch (1023:6): [True: 4, False: 0]
  ------------------
 1024|      4|		if ((r = mac_init(mac)) != 0)
  ------------------
  |  Branch (1024:7): [True: 0, False: 4]
  ------------------
 1025|      0|			return r;
 1026|      4|	}
 1027|      4|	mac->enabled = 1;
 1028|      4|	DBG(debug_f("cipher_init: %s", dir));
 1029|      4|	cipher_free(*ccp);
 1030|      4|	*ccp = NULL;
 1031|      4|	if ((r = cipher_init(ccp, enc->cipher, enc->key, enc->key_len,
  ------------------
  |  Branch (1031:6): [True: 0, False: 4]
  ------------------
 1032|      4|	    enc->iv, enc->iv_len, crypt_type)) != 0)
 1033|      0|		return r;
 1034|      4|	if (!state->cipher_warning_done &&
  ------------------
  |  Branch (1034:6): [True: 4, False: 0]
  ------------------
 1035|      4|	    (wmsg = cipher_warning_message(*ccp)) != NULL) {
  ------------------
  |  Branch (1035:6): [True: 0, False: 4]
  ------------------
 1036|      0|		error("Warning: %s", wmsg);
  ------------------
  |  |  114|      0|#define error(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
 1037|      0|		state->cipher_warning_done = 1;
 1038|      0|	}
 1039|       |	/* Deleting the keys does not gain extra security */
 1040|       |	/* explicit_bzero(enc->iv,  enc->block_size);
 1041|       |	   explicit_bzero(enc->key, enc->key_len);
 1042|       |	   explicit_bzero(mac->key, mac->key_len); */
 1043|      4|	if (((comp->type == COMP_DELAYED && state->after_authentication)) &&
  ------------------
  |  |   64|      8|#define COMP_DELAYED	2
  ------------------
  |  Branch (1043:8): [True: 0, False: 4]
  |  Branch (1043:38): [True: 0, False: 0]
  ------------------
 1044|      0|	    comp->enabled == 0) {
  ------------------
  |  Branch (1044:6): [True: 0, False: 0]
  ------------------
 1045|      0|		if ((r = ssh_packet_init_compression(ssh)) < 0)
  ------------------
  |  Branch (1045:7): [True: 0, False: 0]
  ------------------
 1046|      0|			return r;
 1047|      0|		if (mode == MODE_OUT) {
  ------------------
  |  Branch (1047:7): [True: 0, False: 0]
  ------------------
 1048|      0|			if ((r = start_compression_out(ssh)) != 0)
  ------------------
  |  Branch (1048:8): [True: 0, False: 0]
  ------------------
 1049|      0|				return r;
 1050|      0|		} else {
 1051|      0|			if ((r = start_compression_in(ssh)) != 0)
  ------------------
  |  Branch (1051:8): [True: 0, False: 0]
  ------------------
 1052|      0|				return r;
 1053|      0|		}
 1054|      0|		comp->enabled = 1;
 1055|      0|	}
 1056|       |	/*
 1057|       |	 * The 2^(blocksize*2) limit is too expensive for 3DES,
 1058|       |	 * so enforce a 1GB limit for small blocksizes.
 1059|       |	 * See RFC4344 section 3.2.
 1060|       |	 */
 1061|      4|	if (enc->block_size >= 16)
  ------------------
  |  Branch (1061:6): [True: 4, False: 0]
  ------------------
 1062|      4|		*hard_max_blocks = (uint64_t)1 << (enc->block_size*2);
 1063|      0|	else
 1064|      0|		*hard_max_blocks = ((uint64_t)1 << 30) / enc->block_size;
 1065|      4|	*max_blocks = *hard_max_blocks;
 1066|      4|	if (state->rekey_limit) {
  ------------------
  |  Branch (1066:6): [True: 0, False: 4]
  ------------------
 1067|      0|		*max_blocks = MINIMUM(*max_blocks,
  ------------------
  |  |  268|      0|#define MINIMUM(a, b)	(((a) < (b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (268:24): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1068|      0|		    state->rekey_limit / enc->block_size);
 1069|      0|	}
 1070|       |	debug("rekey %s after %llu blocks", dir,
  ------------------
  |  |  111|      4|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
 1071|      4|	    (unsigned long long)*max_blocks);
 1072|      4|	return 0;
 1073|      4|}
ssh_packet_check_rekey:
 1156|    414|{
 1157|    414|	int r;
 1158|       |
 1159|    414|	if ((r = ssh_packet_check_rekey_preauth(ssh, 0)) != 0)
  ------------------
  |  Branch (1159:6): [True: 0, False: 414]
  ------------------
 1160|      0|		return r;
 1161|    414|	if (!ssh_packet_need_rekeying(ssh, 0))
  ------------------
  |  Branch (1161:6): [True: 414, False: 0]
  ------------------
 1162|    414|		return 0;
 1163|      0|	debug3_f("rekex triggered");
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
 1164|      0|	return kex_start_rekex(ssh);
 1165|    414|}
ssh_packet_log_type:
 1208|  1.23k|{
 1209|  1.23k|	switch (type) {
 1210|      0|	case SSH2_MSG_PING:
  ------------------
  |  |  113|      0|#define SSH2_MSG_PING					192
  ------------------
  |  Branch (1210:2): [True: 0, False: 1.23k]
  ------------------
 1211|      0|	case SSH2_MSG_PONG:
  ------------------
  |  |  114|      0|#define SSH2_MSG_PONG					193
  ------------------
  |  Branch (1211:2): [True: 0, False: 1.23k]
  ------------------
 1212|      0|	case SSH2_MSG_CHANNEL_DATA:
  ------------------
  |  |  142|      0|#define SSH2_MSG_CHANNEL_DATA				94
  ------------------
  |  Branch (1212:2): [True: 0, False: 1.23k]
  ------------------
 1213|      0|	case SSH2_MSG_CHANNEL_EXTENDED_DATA:
  ------------------
  |  |  143|      0|#define SSH2_MSG_CHANNEL_EXTENDED_DATA			95
  ------------------
  |  Branch (1213:2): [True: 0, False: 1.23k]
  ------------------
 1214|      0|	case SSH2_MSG_CHANNEL_WINDOW_ADJUST:
  ------------------
  |  |  141|      0|#define SSH2_MSG_CHANNEL_WINDOW_ADJUST			93
  ------------------
  |  Branch (1214:2): [True: 0, False: 1.23k]
  ------------------
 1215|      0|		return 0;
 1216|  1.23k|	default:
  ------------------
  |  Branch (1216:2): [True: 1.23k, False: 0]
  ------------------
 1217|  1.23k|		return 1;
 1218|  1.23k|	}
 1219|  1.23k|}
ssh_packet_send2_wrapped:
 1226|    816|{
 1227|    816|	struct session_state *state = ssh->state;
 1228|    816|	u_char type, *cp, macbuf[SSH_DIGEST_MAX_LENGTH];
 1229|    816|	u_char tmp, padlen, pad = 0;
 1230|    816|	u_int authlen = 0, aadlen = 0;
 1231|    816|	u_int len;
 1232|    816|	struct sshenc *enc   = NULL;
 1233|    816|	struct sshmac *mac   = NULL;
 1234|    816|	struct sshcomp *comp = NULL;
 1235|    816|	int r, block_size;
 1236|       |
 1237|    816|	if (state->newkeys[MODE_OUT] != NULL) {
  ------------------
  |  Branch (1237:6): [True: 810, False: 6]
  ------------------
 1238|    810|		enc  = &state->newkeys[MODE_OUT]->enc;
 1239|    810|		mac  = &state->newkeys[MODE_OUT]->mac;
 1240|    810|		comp = &state->newkeys[MODE_OUT]->comp;
 1241|       |		/* disable mac for authenticated encryption */
 1242|    810|		if ((authlen = cipher_authlen(enc->cipher)) != 0)
  ------------------
  |  Branch (1242:7): [True: 0, False: 810]
  ------------------
 1243|      0|			mac = NULL;
 1244|    810|	}
 1245|    816|	block_size = enc ? enc->block_size : 8;
  ------------------
  |  Branch (1245:15): [True: 810, False: 6]
  ------------------
 1246|    816|	aadlen = (mac && mac->enabled && mac->etm) || authlen ? 4 : 0;
  ------------------
  |  Branch (1246:12): [True: 810, False: 6]
  |  Branch (1246:19): [True: 810, False: 0]
  |  Branch (1246:35): [True: 0, False: 810]
  |  Branch (1246:48): [True: 0, False: 816]
  ------------------
 1247|       |
 1248|    816|	type = (sshbuf_ptr(state->outgoing_packet))[5];
 1249|    816|	if (ssh_packet_log_type(type))
  ------------------
  |  Branch (1249:6): [True: 816, False: 0]
  ------------------
 1250|    816|		debug3("send packet: type %u", type);
  ------------------
  |  |  109|    816|#define debug3(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
 1251|       |#ifdef PACKET_DEBUG
 1252|       |	fprintf(stderr, "plain:     ");
 1253|       |	sshbuf_dump(state->outgoing_packet, stderr);
 1254|       |#endif
 1255|       |
 1256|    816|	if (comp && comp->enabled) {
  ------------------
  |  Branch (1256:6): [True: 810, False: 6]
  |  Branch (1256:14): [True: 0, False: 810]
  ------------------
 1257|      0|		len = sshbuf_len(state->outgoing_packet);
 1258|       |		/* skip header, compress only payload */
 1259|      0|		if ((r = sshbuf_consume(state->outgoing_packet, 5)) != 0)
  ------------------
  |  Branch (1259:7): [True: 0, False: 0]
  ------------------
 1260|      0|			goto out;
 1261|      0|		sshbuf_reset(state->compression_buffer);
 1262|      0|		if ((r = compress_buffer(ssh, state->outgoing_packet,
  ------------------
  |  Branch (1262:7): [True: 0, False: 0]
  ------------------
 1263|      0|		    state->compression_buffer)) != 0)
 1264|      0|			goto out;
 1265|      0|		sshbuf_reset(state->outgoing_packet);
 1266|      0|		if ((r = sshbuf_put(state->outgoing_packet,
  ------------------
  |  Branch (1266:7): [True: 0, False: 0]
  ------------------
 1267|      0|		    "\0\0\0\0\0", 5)) != 0 ||
 1268|      0|		    (r = sshbuf_putb(state->outgoing_packet,
  ------------------
  |  Branch (1268:7): [True: 0, False: 0]
  ------------------
 1269|      0|		    state->compression_buffer)) != 0)
 1270|      0|			goto out;
 1271|      0|		DBG(debug("compression: raw %d compressed %zd", len,
 1272|      0|		    sshbuf_len(state->outgoing_packet)));
 1273|      0|	}
 1274|       |
 1275|       |	/* sizeof (packet_len + pad_len + payload) */
 1276|    816|	len = sshbuf_len(state->outgoing_packet);
 1277|       |
 1278|       |	/*
 1279|       |	 * calc size of padding, alloc space, get random data,
 1280|       |	 * minimum padding is 4 bytes
 1281|       |	 */
 1282|    816|	len -= aadlen; /* packet length is not encrypted for EtM modes */
 1283|    816|	padlen = block_size - (len % block_size);
 1284|    816|	if (padlen < 4)
  ------------------
  |  Branch (1284:6): [True: 144, False: 672]
  ------------------
 1285|    144|		padlen += block_size;
 1286|    816|	if (state->extra_pad) {
  ------------------
  |  Branch (1286:6): [True: 0, False: 816]
  ------------------
 1287|      0|		tmp = state->extra_pad;
 1288|      0|		state->extra_pad =
 1289|      0|		    ROUNDUP(state->extra_pad, block_size);
  ------------------
  |  |  270|      0|#define ROUNDUP(x, y)   ((((x)+((y)-1))/(y))*(y))
  ------------------
 1290|       |		/* check if roundup overflowed */
 1291|      0|		if (state->extra_pad < tmp)
  ------------------
  |  Branch (1291:7): [True: 0, False: 0]
  ------------------
 1292|      0|			return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
 1293|      0|		tmp = (len + padlen) % state->extra_pad;
 1294|       |		/* Check whether pad calculation below will underflow */
 1295|      0|		if (tmp > state->extra_pad)
  ------------------
  |  Branch (1295:7): [True: 0, False: 0]
  ------------------
 1296|      0|			return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
 1297|      0|		pad = state->extra_pad - tmp;
 1298|      0|		DBG(debug3_f("adding %d (len %d padlen %d extra_pad %d)",
 1299|      0|		    pad, len, padlen, state->extra_pad));
 1300|      0|		tmp = padlen;
 1301|      0|		padlen += pad;
 1302|       |		/* Check whether padlen calculation overflowed */
 1303|      0|		if (padlen < tmp)
  ------------------
  |  Branch (1303:7): [True: 0, False: 0]
  ------------------
 1304|      0|			return SSH_ERR_INVALID_ARGUMENT; /* overflow */
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
 1305|      0|		state->extra_pad = 0;
 1306|      0|	}
 1307|    816|	if ((r = sshbuf_reserve(state->outgoing_packet, padlen, &cp)) != 0)
  ------------------
  |  Branch (1307:6): [True: 0, False: 816]
  ------------------
 1308|      0|		goto out;
 1309|    816|	if (enc && !cipher_ctx_is_plaintext(state->send_context)) {
  ------------------
  |  Branch (1309:6): [True: 810, False: 6]
  |  Branch (1309:13): [True: 810, False: 0]
  ------------------
 1310|       |		/* random padding */
 1311|    810|		arc4random_buf(cp, padlen);
 1312|    810|	} else {
 1313|       |		/* clear padding */
 1314|      6|		explicit_bzero(cp, padlen);
 1315|      6|	}
 1316|       |	/* sizeof (packet_len + pad_len + payload + padding) */
 1317|    816|	len = sshbuf_len(state->outgoing_packet);
 1318|    816|	cp = sshbuf_mutable_ptr(state->outgoing_packet);
 1319|    816|	if (cp == NULL) {
  ------------------
  |  Branch (1319:6): [True: 0, False: 816]
  ------------------
 1320|      0|		r = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 1321|      0|		goto out;
 1322|      0|	}
 1323|       |	/* packet_length includes payload, padding and padding length field */
 1324|    816|	POKE_U32(cp, len - 4);
  ------------------
  |  |  372|    816|	do { \
  |  |  373|    816|		const uint32_t __v = (v); \
  |  |  374|    816|		((u_char *)(p))[0] = (__v >> 24) & 0xff; \
  |  |  375|    816|		((u_char *)(p))[1] = (__v >> 16) & 0xff; \
  |  |  376|    816|		((u_char *)(p))[2] = (__v >> 8) & 0xff; \
  |  |  377|    816|		((u_char *)(p))[3] = __v & 0xff; \
  |  |  378|    816|	} while (0)
  |  |  ------------------
  |  |  |  Branch (378:11): [Folded, False: 816]
  |  |  ------------------
  ------------------
 1325|    816|	cp[4] = padlen;
 1326|    816|	DBG(debug("send: len %d (includes padlen %d, aadlen %d)",
 1327|    816|	    len, padlen, aadlen));
 1328|       |
 1329|       |	/* compute MAC over seqnr and packet(length fields, payload, padding) */
 1330|    816|	if (mac && mac->enabled && !mac->etm) {
  ------------------
  |  Branch (1330:6): [True: 810, False: 6]
  |  Branch (1330:13): [True: 810, False: 0]
  |  Branch (1330:29): [True: 810, False: 0]
  ------------------
 1331|    810|		if ((r = mac_compute(mac, state->p_send.seqnr,
  ------------------
  |  Branch (1331:7): [True: 0, False: 810]
  ------------------
 1332|    810|		    sshbuf_ptr(state->outgoing_packet), len,
 1333|    810|		    macbuf, sizeof(macbuf))) != 0)
 1334|      0|			goto out;
 1335|    810|		DBG(debug("done calc MAC out #%d", state->p_send.seqnr));
 1336|    810|	}
 1337|       |	/* encrypt packet and append to output buffer. */
 1338|    816|	if ((r = sshbuf_reserve(state->output,
  ------------------
  |  Branch (1338:6): [True: 0, False: 816]
  ------------------
 1339|    816|	    sshbuf_len(state->outgoing_packet) + authlen, &cp)) != 0)
 1340|      0|		goto out;
 1341|    816|	if ((r = cipher_crypt(state->send_context, state->p_send.seqnr, cp,
  ------------------
  |  Branch (1341:6): [True: 0, False: 816]
  ------------------
 1342|    816|	    sshbuf_ptr(state->outgoing_packet),
 1343|    816|	    len - aadlen, aadlen, authlen)) != 0)
 1344|      0|		goto out;
 1345|       |	/* append unencrypted MAC */
 1346|    816|	if (mac && mac->enabled) {
  ------------------
  |  Branch (1346:6): [True: 810, False: 6]
  |  Branch (1346:13): [True: 810, False: 0]
  ------------------
 1347|    810|		if (mac->etm) {
  ------------------
  |  Branch (1347:7): [True: 0, False: 810]
  ------------------
 1348|       |			/* EtM: compute mac over aadlen + cipher text */
 1349|      0|			if ((r = mac_compute(mac, state->p_send.seqnr,
  ------------------
  |  Branch (1349:8): [True: 0, False: 0]
  ------------------
 1350|      0|			    cp, len, macbuf, sizeof(macbuf))) != 0)
 1351|      0|				goto out;
 1352|      0|			DBG(debug("done calc MAC(EtM) out #%d",
 1353|      0|			    state->p_send.seqnr));
 1354|      0|		}
 1355|    810|		if ((r = sshbuf_put(state->output, macbuf, mac->mac_len)) != 0)
  ------------------
  |  Branch (1355:7): [True: 0, False: 810]
  ------------------
 1356|      0|			goto out;
 1357|    810|	}
 1358|       |#ifdef PACKET_DEBUG
 1359|       |	fprintf(stderr, "encrypted: ");
 1360|       |	sshbuf_dump(state->output, stderr);
 1361|       |#endif
 1362|       |	/* increment sequence number for outgoing packets */
 1363|    816|	if (++state->p_send.seqnr == 0) {
  ------------------
  |  Branch (1363:6): [True: 0, False: 816]
  ------------------
 1364|      0|		if ((ssh->kex->flags & KEX_INITIAL) != 0) {
  ------------------
  |  |  106|      0|#define KEX_INITIAL			0x0002
  ------------------
  |  Branch (1364:7): [True: 0, False: 0]
  ------------------
 1365|      0|			ssh_packet_disconnect(ssh, "outgoing sequence number "
 1366|      0|			    "wrapped during initial key exchange");
 1367|      0|		}
 1368|      0|		logit("outgoing seqnr wraps around");
  ------------------
  |  |  113|      0|#define logit(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
 1369|      0|	}
 1370|    816|	if (++state->p_send.packets == 0)
  ------------------
  |  Branch (1370:6): [True: 0, False: 816]
  ------------------
 1371|      0|		return SSH_ERR_NEED_REKEY;
  ------------------
  |  |   63|      0|#define SSH_ERR_NEED_REKEY			-39
  ------------------
 1372|    816|	state->p_send.blocks += len / block_size;
 1373|    816|	state->p_send.bytes += len;
 1374|    816|	sshbuf_reset(state->outgoing_packet);
 1375|       |
 1376|    816|	if (type == SSH2_MSG_NEWKEYS && ssh->kex->kex_strict) {
  ------------------
  |  |   94|  1.63k|#define SSH2_MSG_NEWKEYS				21
  ------------------
  |  Branch (1376:6): [True: 2, False: 814]
  |  Branch (1376:34): [True: 2, False: 0]
  ------------------
 1377|      2|		debug_f("resetting send seqnr %u", state->p_send.seqnr);
  ------------------
  |  |  122|      2|#define debug_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
 1378|      2|		state->p_send.seqnr = 0;
 1379|      2|	}
 1380|       |
 1381|    816|	if (type == SSH2_MSG_NEWKEYS)
  ------------------
  |  |   94|    816|#define SSH2_MSG_NEWKEYS				21
  ------------------
  |  Branch (1381:6): [True: 2, False: 814]
  ------------------
 1382|      2|		r = ssh_set_newkeys(ssh, MODE_OUT);
 1383|    814|	else if (type == SSH2_MSG_USERAUTH_SUCCESS && state->server_side)
  ------------------
  |  |  120|  1.62k|#define SSH2_MSG_USERAUTH_SUCCESS			52
  ------------------
  |  Branch (1383:11): [True: 0, False: 814]
  |  Branch (1383:48): [True: 0, False: 0]
  ------------------
 1384|      0|		r = ssh_packet_enable_delayed_compress(ssh);
 1385|    814|	else
 1386|    814|		r = 0;
 1387|    816| out:
 1388|    816|	return r;
 1389|    816|}
ssh_packet_send2:
 1405|    816|{
 1406|    816|	struct session_state *state = ssh->state;
 1407|    816|	struct packet *p;
 1408|    816|	u_char type;
 1409|    816|	int r, need_rekey;
 1410|       |
 1411|    816|	if (sshbuf_len(state->outgoing_packet) < 6)
  ------------------
  |  Branch (1411:6): [True: 0, False: 816]
  ------------------
 1412|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 1413|    816|	type = sshbuf_ptr(state->outgoing_packet)[5];
 1414|    816|	need_rekey = !ssh_packet_type_is_kex(type) &&
  ------------------
  |  Branch (1414:15): [True: 810, False: 6]
  ------------------
 1415|    810|	    ssh_packet_need_rekeying(ssh, sshbuf_len(state->outgoing_packet));
  ------------------
  |  Branch (1415:6): [True: 0, False: 810]
  ------------------
 1416|       |
 1417|       |	/* Enforce hard rekey limit during pre-auth */
 1418|    816|	if (!state->rekeying && !ssh_packet_type_is_kex(type) &&
  ------------------
  |  Branch (1418:6): [True: 810, False: 6]
  |  Branch (1418:26): [True: 810, False: 0]
  ------------------
 1419|    810|	    (r = ssh_packet_check_rekey_preauth(ssh, 0)) != 0)
  ------------------
  |  Branch (1419:6): [True: 0, False: 810]
  ------------------
 1420|      0|		return r;
 1421|       |
 1422|       |	/*
 1423|       |	 * During rekeying we can only send key exchange messages.
 1424|       |	 * Queue everything else.
 1425|       |	 */
 1426|    816|	if ((need_rekey || state->rekeying) && !ssh_packet_type_is_kex(type)) {
  ------------------
  |  Branch (1426:7): [True: 0, False: 816]
  |  Branch (1426:21): [True: 6, False: 810]
  |  Branch (1426:41): [True: 0, False: 6]
  ------------------
 1427|      0|		if (need_rekey)
  ------------------
  |  Branch (1427:7): [True: 0, False: 0]
  ------------------
 1428|      0|			debug3_f("rekex triggered");
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
 1429|      0|		debug("enqueue packet: %u", type);
  ------------------
  |  |  111|      0|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
 1430|      0|		p = calloc(1, sizeof(*p));
 1431|      0|		if (p == NULL)
  ------------------
  |  Branch (1431:7): [True: 0, False: 0]
  ------------------
 1432|      0|			return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 1433|      0|		p->type = type;
 1434|      0|		p->payload = state->outgoing_packet;
 1435|      0|		TAILQ_INSERT_TAIL(&state->outgoing, p, next);
  ------------------
  |  |  572|      0|#define TAILQ_INSERT_TAIL(head, elm, field) do {			\
  |  |  573|      0|	(elm)->field.tqe_next = NULL;					\
  |  |  574|      0|	(elm)->field.tqe_prev = (head)->tqh_last;			\
  |  |  575|      0|	*(head)->tqh_last = (elm);					\
  |  |  576|      0|	(head)->tqh_last = &(elm)->field.tqe_next;			\
  |  |  577|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (577:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1436|      0|		state->outgoing_packet = sshbuf_new();
 1437|      0|		if (state->outgoing_packet == NULL)
  ------------------
  |  Branch (1437:7): [True: 0, False: 0]
  ------------------
 1438|      0|			return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 1439|      0|		if (need_rekey) {
  ------------------
  |  Branch (1439:7): [True: 0, False: 0]
  ------------------
 1440|       |			/*
 1441|       |			 * This packet triggered a rekey, so send the
 1442|       |			 * KEXINIT now.
 1443|       |			 * NB. reenters this function via kex_start_rekex().
 1444|       |			 */
 1445|      0|			return kex_start_rekex(ssh);
 1446|      0|		}
 1447|      0|		return 0;
 1448|      0|	}
 1449|       |
 1450|       |	/* rekeying starts with sending KEXINIT */
 1451|    816|	if (type == SSH2_MSG_KEXINIT)
  ------------------
  |  |   93|    816|#define SSH2_MSG_KEXINIT				20
  ------------------
  |  Branch (1451:6): [True: 2, False: 814]
  ------------------
 1452|      2|		state->rekeying = 1;
 1453|       |
 1454|    816|	if ((r = ssh_packet_send2_wrapped(ssh)) != 0)
  ------------------
  |  Branch (1454:6): [True: 0, False: 816]
  ------------------
 1455|      0|		return r;
 1456|       |
 1457|       |	/* after a NEWKEYS message we can send the complete queue */
 1458|    816|	if (type == SSH2_MSG_NEWKEYS) {
  ------------------
  |  |   94|    816|#define SSH2_MSG_NEWKEYS				21
  ------------------
  |  Branch (1458:6): [True: 2, False: 814]
  ------------------
 1459|      2|		state->rekeying = 0;
 1460|      2|		state->rekey_time = monotime();
 1461|      2|		while ((p = TAILQ_FIRST(&state->outgoing))) {
  ------------------
  |  |  520|      2|#define	TAILQ_FIRST(head)		((head)->tqh_first)
  ------------------
  |  Branch (1461:10): [True: 0, False: 2]
  ------------------
 1462|      0|			type = p->type;
 1463|       |			/*
 1464|       |			 * If this packet triggers a rekex, then skip the
 1465|       |			 * remaining packets in the queue for now.
 1466|       |			 * NB. re-enters this function via kex_start_rekex.
 1467|       |			 */
 1468|      0|			if (ssh_packet_need_rekeying(ssh,
  ------------------
  |  Branch (1468:8): [True: 0, False: 0]
  ------------------
 1469|      0|			    sshbuf_len(p->payload))) {
 1470|      0|				debug3_f("queued packet triggered rekex");
  ------------------
  |  |  120|      0|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
 1471|      0|				return kex_start_rekex(ssh);
 1472|      0|			}
 1473|      0|			debug("dequeue packet: %u", type);
  ------------------
  |  |  111|      0|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
 1474|      0|			sshbuf_free(state->outgoing_packet);
 1475|      0|			state->outgoing_packet = p->payload;
 1476|      0|			TAILQ_REMOVE(&state->outgoing, p, next);
  ------------------
  |  |  596|      0|#define TAILQ_REMOVE(head, elm, field) do {				\
  |  |  597|      0|	if (((elm)->field.tqe_next) != NULL)				\
  |  |  ------------------
  |  |  |  Branch (597:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  598|      0|		(elm)->field.tqe_next->field.tqe_prev =			\
  |  |  599|      0|		    (elm)->field.tqe_prev;				\
  |  |  600|      0|	else								\
  |  |  601|      0|		(head)->tqh_last = (elm)->field.tqe_prev;		\
  |  |  602|      0|	*(elm)->field.tqe_prev = (elm)->field.tqe_next;			\
  |  |  603|      0|	_Q_INVALIDATE((elm)->field.tqe_prev);				\
  |  |  604|      0|	_Q_INVALIDATE((elm)->field.tqe_next);				\
  |  |  605|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (605:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1477|      0|			memset(p, 0, sizeof(*p));
 1478|      0|			free(p);
 1479|      0|			if ((r = ssh_packet_send2_wrapped(ssh)) != 0)
  ------------------
  |  Branch (1479:8): [True: 0, False: 0]
  ------------------
 1480|      0|				return r;
 1481|      0|		}
 1482|      2|	}
 1483|    816|	return 0;
 1484|    816|}
ssh_packet_read_poll2:
 1625|  1.33k|{
 1626|  1.33k|	struct session_state *state = ssh->state;
 1627|  1.33k|	u_int padlen, need;
 1628|  1.33k|	u_char *cp;
 1629|  1.33k|	u_int maclen, aadlen = 0, authlen = 0, block_size;
 1630|  1.33k|	struct sshenc *enc   = NULL;
 1631|  1.33k|	struct sshmac *mac   = NULL;
 1632|  1.33k|	struct sshcomp *comp = NULL;
 1633|  1.33k|	int r;
 1634|       |
 1635|  1.33k|	if (state->mux)
  ------------------
  |  Branch (1635:6): [True: 0, False: 1.33k]
  ------------------
 1636|      0|		return ssh_packet_read_poll2_mux(ssh, typep, seqnr_p);
 1637|       |
 1638|  1.33k|	*typep = SSH_MSG_NONE;
  ------------------
  |  |   61|  1.33k|#define SSH_MSG_NONE					0
  ------------------
 1639|       |
 1640|  1.33k|	if (state->packet_discard)
  ------------------
  |  Branch (1640:6): [True: 0, False: 1.33k]
  ------------------
 1641|      0|		return 0;
 1642|       |
 1643|  1.33k|	if (state->newkeys[MODE_IN] != NULL) {
  ------------------
  |  Branch (1643:6): [True: 1.32k, False: 8]
  ------------------
 1644|  1.32k|		enc  = &state->newkeys[MODE_IN]->enc;
 1645|  1.32k|		mac  = &state->newkeys[MODE_IN]->mac;
 1646|  1.32k|		comp = &state->newkeys[MODE_IN]->comp;
 1647|       |		/* disable mac for authenticated encryption */
 1648|  1.32k|		if ((authlen = cipher_authlen(enc->cipher)) != 0)
  ------------------
  |  Branch (1648:7): [True: 0, False: 1.32k]
  ------------------
 1649|      0|			mac = NULL;
 1650|  1.32k|	}
 1651|  1.33k|	maclen = mac && mac->enabled ? mac->mac_len : 0;
  ------------------
  |  Branch (1651:11): [True: 1.32k, False: 8]
  |  Branch (1651:18): [True: 1.32k, False: 0]
  ------------------
 1652|  1.33k|	block_size = enc ? enc->block_size : 8;
  ------------------
  |  Branch (1652:15): [True: 1.32k, False: 8]
  ------------------
 1653|  1.33k|	aadlen = (mac && mac->enabled && mac->etm) || authlen ? 4 : 0;
  ------------------
  |  Branch (1653:12): [True: 1.32k, False: 8]
  |  Branch (1653:19): [True: 1.32k, False: 0]
  |  Branch (1653:35): [True: 0, False: 1.32k]
  |  Branch (1653:48): [True: 0, False: 1.33k]
  ------------------
 1654|       |
 1655|  1.33k|	if (aadlen && state->packlen == 0) {
  ------------------
  |  Branch (1655:6): [True: 0, False: 1.33k]
  |  Branch (1655:16): [True: 0, False: 0]
  ------------------
 1656|      0|		if (cipher_get_length(state->receive_context,
  ------------------
  |  Branch (1656:7): [True: 0, False: 0]
  ------------------
 1657|      0|		    &state->packlen, state->p_read.seqnr,
 1658|      0|		    sshbuf_ptr(state->input), sshbuf_len(state->input)) != 0)
 1659|      0|			return 0;
 1660|      0|		if (state->packlen < 1 + 4 ||
  ------------------
  |  Branch (1660:7): [True: 0, False: 0]
  ------------------
 1661|      0|		    state->packlen > PACKET_MAX_SIZE) {
  ------------------
  |  |   98|      0|#define PACKET_MAX_SIZE (256 * 1024)
  ------------------
  |  Branch (1661:7): [True: 0, False: 0]
  ------------------
 1662|       |#ifdef PACKET_DEBUG
 1663|       |			sshbuf_dump(state->input, stderr);
 1664|       |#endif
 1665|      0|			logit("Bad packet length %u.", state->packlen);
  ------------------
  |  |  113|      0|#define logit(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
 1666|      0|			if ((r = sshpkt_disconnect(ssh, "Packet corrupt")) != 0)
  ------------------
  |  Branch (1666:8): [True: 0, False: 0]
  ------------------
 1667|      0|				return r;
 1668|      0|			return SSH_ERR_CONN_CORRUPT;
  ------------------
  |  |   78|      0|#define SSH_ERR_CONN_CORRUPT			-54
  ------------------
 1669|      0|		}
 1670|      0|		sshbuf_reset(state->incoming_packet);
 1671|  1.33k|	} else if (state->packlen == 0) {
  ------------------
  |  Branch (1671:13): [True: 1.33k, False: 0]
  ------------------
 1672|       |		/*
 1673|       |		 * check if input size is less than the cipher block size,
 1674|       |		 * decrypt first block and extract length of incoming packet
 1675|       |		 */
 1676|  1.33k|		if (sshbuf_len(state->input) < block_size)
  ------------------
  |  Branch (1676:7): [True: 811, False: 521]
  ------------------
 1677|    811|			return 0;
 1678|    521|		sshbuf_reset(state->incoming_packet);
 1679|    521|		if ((r = sshbuf_reserve(state->incoming_packet, block_size,
  ------------------
  |  Branch (1679:7): [True: 107, False: 414]
  ------------------
 1680|    521|		    &cp)) != 0)
 1681|    107|			goto out;
 1682|    414|		if ((r = cipher_crypt(state->receive_context,
  ------------------
  |  Branch (1682:7): [True: 0, False: 414]
  ------------------
 1683|    414|		    state->p_send.seqnr, cp, sshbuf_ptr(state->input),
 1684|    414|		    block_size, 0, 0)) != 0)
 1685|      0|			goto out;
 1686|    414|		state->packlen = PEEK_U32(sshbuf_ptr(state->incoming_packet));
  ------------------
  |  |  351|    414|	(((uint32_t)(((const u_char *)(p))[0]) << 24) | \
  |  |  352|    414|	 ((uint32_t)(((const u_char *)(p))[1]) << 16) | \
  |  |  353|    414|	 ((uint32_t)(((const u_char *)(p))[2]) << 8) | \
  |  |  354|    414|	  (uint32_t)(((const u_char *)(p))[3]))
  ------------------
 1687|    414|		if (state->packlen < 1 + 4 ||
  ------------------
  |  Branch (1687:7): [True: 0, False: 414]
  ------------------
 1688|    414|		    state->packlen > PACKET_MAX_SIZE) {
  ------------------
  |  |   98|    414|#define PACKET_MAX_SIZE (256 * 1024)
  ------------------
  |  Branch (1688:7): [True: 0, False: 414]
  ------------------
 1689|       |#ifdef PACKET_DEBUG
 1690|       |			fprintf(stderr, "input: \n");
 1691|       |			sshbuf_dump(state->input, stderr);
 1692|       |			fprintf(stderr, "incoming_packet: \n");
 1693|       |			sshbuf_dump(state->incoming_packet, stderr);
 1694|       |#endif
 1695|      0|			logit("Bad packet length %u.", state->packlen);
  ------------------
  |  |  113|      0|#define logit(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
 1696|      0|			return ssh_packet_start_discard(ssh, enc, mac, 0,
 1697|      0|			    PACKET_MAX_SIZE);
  ------------------
  |  |   98|      0|#define PACKET_MAX_SIZE (256 * 1024)
  ------------------
 1698|      0|		}
 1699|    414|		if ((r = sshbuf_consume(state->input, block_size)) != 0)
  ------------------
  |  Branch (1699:7): [True: 0, False: 414]
  ------------------
 1700|      0|			goto out;
 1701|    414|	}
 1702|    414|	DBG(debug("input: packet len %u", state->packlen+4));
 1703|       |
 1704|    414|	if (aadlen) {
  ------------------
  |  Branch (1704:6): [True: 0, False: 414]
  ------------------
 1705|       |		/* only the payload is encrypted */
 1706|      0|		need = state->packlen;
 1707|    414|	} else {
 1708|       |		/*
 1709|       |		 * the payload size and the payload are encrypted, but we
 1710|       |		 * have a partial packet of block_size bytes
 1711|       |		 */
 1712|    414|		need = 4 + state->packlen - block_size;
 1713|    414|	}
 1714|    414|	DBG(debug("partial packet: block %d, need %d, maclen %d, authlen %d,"
 1715|    414|	    " aadlen %d", block_size, need, maclen, authlen, aadlen));
 1716|    414|	if (need % block_size != 0) {
  ------------------
  |  Branch (1716:6): [True: 0, False: 414]
  ------------------
 1717|      0|		logit("padding error: need %d block %d mod %d",
  ------------------
  |  |  113|      0|#define logit(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
 1718|      0|		    need, block_size, need % block_size);
 1719|      0|		return ssh_packet_start_discard(ssh, enc, mac, 0,
 1720|      0|		    PACKET_MAX_SIZE - block_size);
  ------------------
  |  |   98|      0|#define PACKET_MAX_SIZE (256 * 1024)
  ------------------
 1721|      0|	}
 1722|       |	/*
 1723|       |	 * check if the entire packet has been received and
 1724|       |	 * decrypt into incoming_packet:
 1725|       |	 * 'aadlen' bytes are unencrypted, but authenticated.
 1726|       |	 * 'need' bytes are encrypted, followed by either
 1727|       |	 * 'authlen' bytes of authentication tag or
 1728|       |	 * 'maclen' bytes of message authentication code.
 1729|       |	 */
 1730|    414|	if (sshbuf_len(state->input) < aadlen + need + authlen + maclen)
  ------------------
  |  Branch (1730:6): [True: 0, False: 414]
  ------------------
 1731|      0|		return 0; /* packet is incomplete */
 1732|       |#ifdef PACKET_DEBUG
 1733|       |	fprintf(stderr, "read_poll enc/full: ");
 1734|       |	sshbuf_dump(state->input, stderr);
 1735|       |#endif
 1736|       |	/* EtM: check mac over encrypted input */
 1737|    414|	if (mac && mac->enabled && mac->etm) {
  ------------------
  |  Branch (1737:6): [True: 408, False: 6]
  |  Branch (1737:13): [True: 408, False: 0]
  |  Branch (1737:29): [True: 0, False: 408]
  ------------------
 1738|      0|		if ((r = mac_check(mac, state->p_read.seqnr,
  ------------------
  |  Branch (1738:7): [True: 0, False: 0]
  ------------------
 1739|      0|		    sshbuf_ptr(state->input), aadlen + need,
 1740|      0|		    sshbuf_ptr(state->input) + aadlen + need + authlen,
 1741|      0|		    maclen)) != 0) {
 1742|      0|			if (r == SSH_ERR_MAC_INVALID)
  ------------------
  |  |   54|      0|#define SSH_ERR_MAC_INVALID			-30
  ------------------
  |  Branch (1742:8): [True: 0, False: 0]
  ------------------
 1743|      0|				logit("Corrupted MAC on input.");
  ------------------
  |  |  113|      0|#define logit(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
 1744|      0|			goto out;
 1745|      0|		}
 1746|      0|	}
 1747|    414|	if ((r = sshbuf_reserve(state->incoming_packet, aadlen + need,
  ------------------
  |  Branch (1747:6): [True: 0, False: 414]
  ------------------
 1748|    414|	    &cp)) != 0)
 1749|      0|		goto out;
 1750|    414|	if ((r = cipher_crypt(state->receive_context, state->p_read.seqnr, cp,
  ------------------
  |  Branch (1750:6): [True: 0, False: 414]
  ------------------
 1751|    414|	    sshbuf_ptr(state->input), need, aadlen, authlen)) != 0)
 1752|      0|		goto out;
 1753|    414|	if ((r = sshbuf_consume(state->input, aadlen + need + authlen)) != 0)
  ------------------
  |  Branch (1753:6): [True: 0, False: 414]
  ------------------
 1754|      0|		goto out;
 1755|    414|	if (mac && mac->enabled) {
  ------------------
  |  Branch (1755:6): [True: 408, False: 6]
  |  Branch (1755:13): [True: 408, False: 0]
  ------------------
 1756|       |		/* Not EtM: check MAC over cleartext */
 1757|    408|		if (!mac->etm && (r = mac_check(mac, state->p_read.seqnr,
  ------------------
  |  Branch (1757:7): [True: 408, False: 0]
  |  Branch (1757:20): [True: 0, False: 408]
  ------------------
 1758|    408|		    sshbuf_ptr(state->incoming_packet),
 1759|    408|		    sshbuf_len(state->incoming_packet),
 1760|    408|		    sshbuf_ptr(state->input), maclen)) != 0) {
 1761|      0|			if (r != SSH_ERR_MAC_INVALID)
  ------------------
  |  |   54|      0|#define SSH_ERR_MAC_INVALID			-30
  ------------------
  |  Branch (1761:8): [True: 0, False: 0]
  ------------------
 1762|      0|				goto out;
 1763|      0|			logit("Corrupted MAC on input.");
  ------------------
  |  |  113|      0|#define logit(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
 1764|      0|			if (need + block_size > PACKET_MAX_SIZE)
  ------------------
  |  |   98|      0|#define PACKET_MAX_SIZE (256 * 1024)
  ------------------
  |  Branch (1764:8): [True: 0, False: 0]
  ------------------
 1765|      0|				return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 1766|      0|			return ssh_packet_start_discard(ssh, enc, mac,
 1767|      0|			    sshbuf_len(state->incoming_packet),
 1768|      0|			    PACKET_MAX_SIZE - need - block_size);
  ------------------
  |  |   98|      0|#define PACKET_MAX_SIZE (256 * 1024)
  ------------------
 1769|      0|		}
 1770|       |		/* Remove MAC from input buffer */
 1771|    408|		DBG(debug("MAC #%d ok", state->p_read.seqnr));
 1772|    408|		if ((r = sshbuf_consume(state->input, mac->mac_len)) != 0)
  ------------------
  |  Branch (1772:7): [True: 0, False: 408]
  ------------------
 1773|      0|			goto out;
 1774|    408|	}
 1775|       |
 1776|    414|	if (seqnr_p != NULL)
  ------------------
  |  Branch (1776:6): [True: 414, False: 0]
  ------------------
 1777|    414|		*seqnr_p = state->p_read.seqnr;
 1778|    414|	if (++state->p_read.seqnr == 0) {
  ------------------
  |  Branch (1778:6): [True: 0, False: 414]
  ------------------
 1779|      0|		if ((ssh->kex->flags & KEX_INITIAL) != 0) {
  ------------------
  |  |  106|      0|#define KEX_INITIAL			0x0002
  ------------------
  |  Branch (1779:7): [True: 0, False: 0]
  ------------------
 1780|      0|			ssh_packet_disconnect(ssh, "incoming sequence number "
 1781|      0|			    "wrapped during initial key exchange");
 1782|      0|		}
 1783|      0|		logit("incoming seqnr wraps around");
  ------------------
  |  |  113|      0|#define logit(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, NULL, __VA_ARGS__)
  ------------------
 1784|      0|	}
 1785|    414|	if (++state->p_read.packets == 0)
  ------------------
  |  Branch (1785:6): [True: 0, False: 414]
  ------------------
 1786|      0|		return SSH_ERR_NEED_REKEY;
  ------------------
  |  |   63|      0|#define SSH_ERR_NEED_REKEY			-39
  ------------------
 1787|    414|	state->p_read.blocks += (state->packlen + 4) / block_size;
 1788|    414|	state->p_read.bytes += state->packlen + 4;
 1789|       |
 1790|       |	/* get padlen */
 1791|    414|	padlen = sshbuf_ptr(state->incoming_packet)[4];
 1792|    414|	DBG(debug("input: padlen %d", padlen));
 1793|    414|	if (padlen < 4)	{
  ------------------
  |  Branch (1793:6): [True: 0, False: 414]
  ------------------
 1794|      0|		if ((r = sshpkt_disconnect(ssh,
  ------------------
  |  Branch (1794:7): [True: 0, False: 0]
  ------------------
 1795|      0|		    "Corrupted padlen %d on input.", padlen)) != 0 ||
 1796|      0|		    (r = ssh_packet_write_wait(ssh)) != 0)
  ------------------
  |  Branch (1796:7): [True: 0, False: 0]
  ------------------
 1797|      0|			return r;
 1798|      0|		return SSH_ERR_CONN_CORRUPT;
  ------------------
  |  |   78|      0|#define SSH_ERR_CONN_CORRUPT			-54
  ------------------
 1799|      0|	}
 1800|       |
 1801|       |	/* skip packet size + padlen, discard padding */
 1802|    414|	if ((r = sshbuf_consume(state->incoming_packet, 4 + 1)) != 0 ||
  ------------------
  |  Branch (1802:6): [True: 0, False: 414]
  ------------------
 1803|    414|	    ((r = sshbuf_consume_end(state->incoming_packet, padlen)) != 0))
  ------------------
  |  Branch (1803:6): [True: 0, False: 414]
  ------------------
 1804|      0|		goto out;
 1805|       |
 1806|    414|	DBG(debug("input: len before de-compress %zd",
 1807|    414|	    sshbuf_len(state->incoming_packet)));
 1808|    414|	if (comp && comp->enabled) {
  ------------------
  |  Branch (1808:6): [True: 408, False: 6]
  |  Branch (1808:14): [True: 0, False: 408]
  ------------------
 1809|      0|		sshbuf_reset(state->compression_buffer);
 1810|      0|		if ((r = uncompress_buffer(ssh, state->incoming_packet,
  ------------------
  |  Branch (1810:7): [True: 0, False: 0]
  ------------------
 1811|      0|		    state->compression_buffer)) != 0)
 1812|      0|			goto out;
 1813|      0|		sshbuf_reset(state->incoming_packet);
 1814|      0|		if ((r = sshbuf_putb(state->incoming_packet,
  ------------------
  |  Branch (1814:7): [True: 0, False: 0]
  ------------------
 1815|      0|		    state->compression_buffer)) != 0)
 1816|      0|			goto out;
 1817|      0|		DBG(debug("input: len after de-compress %zd",
 1818|      0|		    sshbuf_len(state->incoming_packet)));
 1819|      0|	}
 1820|       |	/*
 1821|       |	 * get packet type, implies consume.
 1822|       |	 * return length of payload (without type field)
 1823|       |	 */
 1824|    414|	if ((r = sshbuf_get_u8(state->incoming_packet, typep)) != 0)
  ------------------
  |  Branch (1824:6): [True: 0, False: 414]
  ------------------
 1825|      0|		goto out;
 1826|    414|	if (ssh_packet_log_type(*typep))
  ------------------
  |  Branch (1826:6): [True: 414, False: 0]
  ------------------
 1827|    414|		debug3("receive packet: type %u", *typep);
  ------------------
  |  |  109|    414|#define debug3(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
 1828|    414|	if (*typep < SSH2_MSG_MIN) {
  ------------------
  |  |   77|    414|#define SSH2_MSG_MIN					1
  ------------------
  |  Branch (1828:6): [True: 0, False: 414]
  ------------------
 1829|      0|		if ((r = sshpkt_disconnect(ssh,
  ------------------
  |  Branch (1829:7): [True: 0, False: 0]
  ------------------
 1830|      0|		    "Invalid ssh2 packet type: %d", *typep)) != 0 ||
 1831|      0|		    (r = ssh_packet_write_wait(ssh)) != 0)
  ------------------
  |  Branch (1831:7): [True: 0, False: 0]
  ------------------
 1832|      0|			return r;
 1833|      0|		return SSH_ERR_PROTOCOL_ERROR;
  ------------------
  |  |   79|      0|#define SSH_ERR_PROTOCOL_ERROR			-55
  ------------------
 1834|      0|	}
 1835|    414|	if (state->hook_in != NULL &&
  ------------------
  |  Branch (1835:6): [True: 0, False: 414]
  ------------------
 1836|      0|	    (r = state->hook_in(ssh, state->incoming_packet, typep,
  ------------------
  |  Branch (1836:6): [True: 0, False: 0]
  ------------------
 1837|      0|	    state->hook_in_ctx)) != 0)
 1838|      0|		return r;
 1839|    414|	if (*typep == SSH2_MSG_USERAUTH_SUCCESS && !state->server_side)
  ------------------
  |  |  120|    828|#define SSH2_MSG_USERAUTH_SUCCESS			52
  ------------------
  |  Branch (1839:6): [True: 0, False: 414]
  |  Branch (1839:45): [True: 0, False: 0]
  ------------------
 1840|      0|		r = ssh_packet_enable_delayed_compress(ssh);
 1841|    414|	else
 1842|    414|		r = 0;
 1843|       |#ifdef PACKET_DEBUG
 1844|       |	fprintf(stderr, "read/plain[%d]:\r\n", *typep);
 1845|       |	sshbuf_dump(state->incoming_packet, stderr);
 1846|       |#endif
 1847|       |	/* reset for next packet */
 1848|    414|	state->packlen = 0;
 1849|    414|	if (*typep == SSH2_MSG_NEWKEYS && ssh->kex->kex_strict) {
  ------------------
  |  |   94|    828|#define SSH2_MSG_NEWKEYS				21
  ------------------
  |  Branch (1849:6): [True: 2, False: 412]
  |  Branch (1849:36): [True: 2, False: 0]
  ------------------
 1850|      2|		debug_f("resetting read seqnr %u", state->p_read.seqnr);
  ------------------
  |  |  122|      2|#define debug_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
 1851|      2|		state->p_read.seqnr = 0;
 1852|      2|	}
 1853|       |
 1854|    414|	if ((r = ssh_packet_check_rekey(ssh)) != 0)
  ------------------
  |  Branch (1854:6): [True: 0, False: 414]
  ------------------
 1855|      0|		return r;
 1856|    521| out:
 1857|    521|	return r;
 1858|    414|}
ssh_packet_read_poll_seqnr:
 1862|    808|{
 1863|    808|	struct session_state *state = ssh->state;
 1864|    808|	u_int reason, seqnr;
 1865|    808|	int r;
 1866|    808|	u_char *msg;
 1867|    808|	const u_char *d;
 1868|    808|	size_t len;
 1869|       |
 1870|    808|	for (;;) {
 1871|    808|		msg = NULL;
 1872|    808|		r = ssh_packet_read_poll2(ssh, typep, seqnr_p);
 1873|    808|		if (r != 0)
  ------------------
  |  Branch (1873:7): [True: 107, False: 701]
  ------------------
 1874|    107|			return r;
 1875|    701|		if (*typep == 0) {
  ------------------
  |  Branch (1875:7): [True: 295, False: 406]
  ------------------
 1876|       |			/* no message ready */
 1877|    295|			return 0;
 1878|    295|		}
 1879|    406|		state->keep_alive_timeouts = 0;
 1880|    406|		DBG(debug("received packet type %d", *typep));
 1881|       |
 1882|       |		/* Always process disconnect messages */
 1883|    406|		if (*typep == SSH2_MSG_DISCONNECT) {
  ------------------
  |  |   82|    406|#define SSH2_MSG_DISCONNECT				1
  ------------------
  |  Branch (1883:7): [True: 0, False: 406]
  ------------------
 1884|      0|			if ((r = sshpkt_get_u32(ssh, &reason)) != 0 ||
  ------------------
  |  Branch (1884:8): [True: 0, False: 0]
  ------------------
 1885|      0|			    (r = sshpkt_get_string(ssh, &msg, NULL)) != 0)
  ------------------
  |  Branch (1885:8): [True: 0, False: 0]
  ------------------
 1886|      0|				return r;
 1887|       |			/* Ignore normal client exit notifications */
 1888|      0|			do_log2(ssh->state->server_side &&
  ------------------
  |  |  108|      0|#define do_log2(level, ...)	sshlog(__FILE__, __func__, __LINE__, 0, level, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (108:69): [True: 0, False: 0]
  |  |  |  Branch (108:69): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1889|      0|			    reason == SSH2_DISCONNECT_BY_APPLICATION ?
 1890|      0|			    SYSLOG_LEVEL_INFO : SYSLOG_LEVEL_ERROR,
 1891|      0|			    "Received disconnect from %s port %d:"
 1892|      0|			    "%u: %.400s", ssh_remote_ipaddr(ssh),
 1893|      0|			    ssh_remote_port(ssh), reason, msg);
 1894|      0|			free(msg);
 1895|      0|			return SSH_ERR_DISCONNECTED;
  ------------------
  |  |   53|      0|#define SSH_ERR_DISCONNECTED			-29
  ------------------
 1896|      0|		}
 1897|       |
 1898|       |		/*
 1899|       |		 * Do not implicitly handle any messages here during initial
 1900|       |		 * KEX when in strict mode. They will be need to be allowed
 1901|       |		 * explicitly by the KEX dispatch table or they will generate
 1902|       |		 * protocol errors.
 1903|       |		 */
 1904|    406|		if (ssh->kex != NULL &&
  ------------------
  |  Branch (1904:7): [True: 406, False: 0]
  ------------------
 1905|    406|		    (ssh->kex->flags & KEX_INITIAL) && ssh->kex->kex_strict)
  ------------------
  |  |  106|    406|#define KEX_INITIAL			0x0002
  ------------------
  |  Branch (1905:7): [True: 0, False: 406]
  |  Branch (1905:42): [True: 0, False: 0]
  ------------------
 1906|      0|			return 0;
 1907|       |		/* Implicitly handle transport-level messages */
 1908|    406|		switch (*typep) {
 1909|      0|		case SSH2_MSG_IGNORE:
  ------------------
  |  |   83|      0|#define SSH2_MSG_IGNORE					2
  ------------------
  |  Branch (1909:3): [True: 0, False: 406]
  ------------------
 1910|      0|			debug3("Received SSH2_MSG_IGNORE");
  ------------------
  |  |  109|      0|#define debug3(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
 1911|      0|			break;
 1912|      0|		case SSH2_MSG_DEBUG:
  ------------------
  |  |   85|      0|#define SSH2_MSG_DEBUG					4
  ------------------
  |  Branch (1912:3): [True: 0, False: 406]
  ------------------
 1913|      0|			if ((r = sshpkt_get_u8(ssh, NULL)) != 0 ||
  ------------------
  |  Branch (1913:8): [True: 0, False: 0]
  ------------------
 1914|      0|			    (r = sshpkt_get_string(ssh, &msg, NULL)) != 0 ||
  ------------------
  |  Branch (1914:8): [True: 0, False: 0]
  ------------------
 1915|      0|			    (r = sshpkt_get_string(ssh, NULL, NULL)) != 0) {
  ------------------
  |  Branch (1915:8): [True: 0, False: 0]
  ------------------
 1916|      0|				free(msg);
 1917|      0|				return r;
 1918|      0|			}
 1919|      0|			debug("Remote: %.900s", msg);
  ------------------
  |  |  111|      0|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
 1920|      0|			free(msg);
 1921|      0|			break;
 1922|      0|		case SSH2_MSG_UNIMPLEMENTED:
  ------------------
  |  |   84|      0|#define SSH2_MSG_UNIMPLEMENTED				3
  ------------------
  |  Branch (1922:3): [True: 0, False: 406]
  ------------------
 1923|      0|			if ((r = sshpkt_get_u32(ssh, &seqnr)) != 0)
  ------------------
  |  Branch (1923:8): [True: 0, False: 0]
  ------------------
 1924|      0|				return r;
 1925|      0|			debug("Received SSH2_MSG_UNIMPLEMENTED for %u",
  ------------------
  |  |  111|      0|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
 1926|      0|			    seqnr);
 1927|      0|			break;
 1928|      0|		case SSH2_MSG_PING:
  ------------------
  |  |  113|      0|#define SSH2_MSG_PING					192
  ------------------
  |  Branch (1928:3): [True: 0, False: 406]
  ------------------
 1929|      0|			if ((r = sshpkt_get_string_direct(ssh, &d, &len)) != 0)
  ------------------
  |  Branch (1929:8): [True: 0, False: 0]
  ------------------
 1930|      0|				return r;
 1931|      0|			DBG(debug("Received SSH2_MSG_PING len %zu", len));
 1932|      0|			if (!ssh->state->after_authentication) {
  ------------------
  |  Branch (1932:8): [True: 0, False: 0]
  ------------------
 1933|      0|				DBG(debug("Won't reply to PING in preauth"));
 1934|      0|				break;
 1935|      0|			}
 1936|      0|			if (ssh_packet_is_rekeying(ssh)) {
  ------------------
  |  Branch (1936:8): [True: 0, False: 0]
  ------------------
 1937|      0|				DBG(debug("Won't reply to PING during KEX"));
 1938|      0|				break;
 1939|      0|			}
 1940|      0|			if ((r = sshpkt_start(ssh, SSH2_MSG_PONG)) != 0 ||
  ------------------
  |  |  114|      0|#define SSH2_MSG_PONG					193
  ------------------
  |  Branch (1940:8): [True: 0, False: 0]
  ------------------
 1941|      0|			    (r = sshpkt_put_string(ssh, d, len)) != 0 ||
  ------------------
  |  Branch (1941:8): [True: 0, False: 0]
  ------------------
 1942|      0|			    (r = sshpkt_send(ssh)) != 0)
  ------------------
  |  Branch (1942:8): [True: 0, False: 0]
  ------------------
 1943|      0|				return r;
 1944|      0|			break;
 1945|      0|		case SSH2_MSG_PONG:
  ------------------
  |  |  114|      0|#define SSH2_MSG_PONG					193
  ------------------
  |  Branch (1945:3): [True: 0, False: 406]
  ------------------
 1946|      0|			if ((r = sshpkt_get_string_direct(ssh,
  ------------------
  |  Branch (1946:8): [True: 0, False: 0]
  ------------------
 1947|      0|			    NULL, &len)) != 0)
 1948|      0|				return r;
 1949|      0|			DBG(debug("Received SSH2_MSG_PONG len %zu", len));
 1950|      0|			break;
 1951|    406|		default:
  ------------------
  |  Branch (1951:3): [True: 406, False: 0]
  ------------------
 1952|    406|			if (ssh->kex != NULL &&
  ------------------
  |  Branch (1952:8): [True: 406, False: 0]
  ------------------
 1953|    406|			    (ssh->kex->flags & KEX_INIT_RECVD) != 0 &&
  ------------------
  |  |  113|    406|#define KEX_INIT_RECVD			0x0100
  ------------------
  |  Branch (1953:8): [True: 0, False: 406]
  ------------------
 1954|      0|			    !ssh_packet_type_is_kex(*typep)) {
  ------------------
  |  Branch (1954:8): [True: 0, False: 0]
  ------------------
 1955|      0|				error("non-transport message %u received "
  ------------------
  |  |  114|      0|#define error(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
 1956|      0|				    "from peer during key exchange", *typep);
 1957|      0|				return SSH_ERR_PROTOCOL_ERROR;
  ------------------
  |  |   79|      0|#define SSH_ERR_PROTOCOL_ERROR			-55
  ------------------
 1958|      0|			}
 1959|    406|			return 0;
 1960|    406|		}
 1961|    406|	}
 1962|    808|}
ssh_packet_set_server:
 2380|      1|{
 2381|      1|	ssh->state->server_side = 1;
 2382|      1|	ssh->kex->server = 1; /* XXX unify? */
 2383|      1|}
ssh_packet_get_input:
 2393|    522|{
 2394|    522|	return (void *)ssh->state->input;
 2395|    522|}
ssh_packet_get_output:
 2399|  1.04k|{
 2400|  1.04k|	return (void *)ssh->state->output;
 2401|  1.04k|}
sshpkt_put:
 2708|    513|{
 2709|    513|	return sshbuf_put(ssh->state->outgoing_packet, v, len);
 2710|    513|}
sshpkt_putb:
 2714|      4|{
 2715|      4|	return sshbuf_putb(ssh->state->outgoing_packet, b);
 2716|      4|}
sshpkt_put_u8:
 2720|    295|{
 2721|    295|	return sshbuf_put_u8(ssh->state->outgoing_packet, val);
 2722|    295|}
sshpkt_put_string:
 2738|      1|{
 2739|      1|	return sshbuf_put_string(ssh->state->outgoing_packet, v, len);
 2740|      1|}
sshpkt_put_cstring:
 2744|    295|{
 2745|    295|	return sshbuf_put_cstring(ssh->state->outgoing_packet, v);
 2746|    295|}
sshpkt_put_stringb:
 2750|      3|{
 2751|      3|	return sshbuf_put_stringb(ssh->state->outgoing_packet, v);
 2752|      3|}
sshpkt_get_u8:
 2784|     68|{
 2785|     68|	return sshbuf_get_u8(ssh->state->incoming_packet, valp);
 2786|     68|}
sshpkt_get_u32:
 2790|      2|{
 2791|      2|	return sshbuf_get_u32(ssh->state->incoming_packet, valp);
 2792|      2|}
sshpkt_get_string:
 2802|     21|{
 2803|     21|	return sshbuf_get_string(ssh->state->incoming_packet, valp, lenp);
 2804|     21|}
sshpkt_get_cstring:
 2820|  1.14k|{
 2821|  1.14k|	return sshbuf_get_cstring(ssh->state->incoming_packet, valp, lenp);
 2822|  1.14k|}
sshpkt_getb_froms:
 2826|     23|{
 2827|     23|	return sshbuf_froms(ssh->state->incoming_packet, valp);
 2828|     23|}
sshpkt_get_end:
 2846|     18|{
 2847|     18|	if (sshbuf_len(ssh->state->incoming_packet) > 0)
  ------------------
  |  Branch (2847:6): [True: 2, False: 16]
  ------------------
 2848|      2|		return SSH_ERR_UNEXPECTED_TRAILING_DATA;
  ------------------
  |  |   47|      2|#define SSH_ERR_UNEXPECTED_TRAILING_DATA	-23
  ------------------
 2849|     16|	return 0;
 2850|     18|}
sshpkt_ptr:
 2854|      2|{
 2855|      2|	if (lenp != NULL)
  ------------------
  |  Branch (2855:6): [True: 2, False: 0]
  ------------------
 2856|      2|		*lenp = sshbuf_len(ssh->state->incoming_packet);
 2857|      2|	return sshbuf_ptr(ssh->state->incoming_packet);
 2858|      2|}
sshpkt_start:
 2864|    816|{
 2865|    816|	u_char buf[6]; /* u32 packet length, u8 pad len, u8 type */
 2866|       |
 2867|    816|	DBG(debug("packet_start[%d]", type));
 2868|    816|	memset(buf, 0, sizeof(buf));
 2869|    816|	buf[sizeof(buf) - 1] = type;
 2870|    816|	sshbuf_reset(ssh->state->outgoing_packet);
 2871|    816|	return sshbuf_put(ssh->state->outgoing_packet, buf, sizeof(buf));
 2872|    816|}
sshpkt_send:
 2939|    816|{
 2940|    816|	if (ssh->state && ssh->state->mux)
  ------------------
  |  Branch (2940:6): [True: 816, False: 0]
  |  Branch (2940:20): [True: 0, False: 816]
  ------------------
 2941|      0|		return ssh_packet_send_mux(ssh);
 2942|    816|	return ssh_packet_send2(ssh);
 2943|    816|}
packet.c:ssh_packet_check_rekey_preauth:
 1143|  1.22k|{
 1144|  1.22k|	if (ssh->state->after_authentication)
  ------------------
  |  Branch (1144:6): [True: 0, False: 1.22k]
  ------------------
 1145|      0|		return 0;
 1146|       |
 1147|  1.22k|	if (ssh_packet_check_rekey_blocklimit(ssh, 0, 1)) {
  ------------------
  |  Branch (1147:6): [True: 0, False: 1.22k]
  ------------------
 1148|      0|		error("RekeyLimit exceeded before authentication completed");
  ------------------
  |  |  114|      0|#define error(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_ERROR, NULL, __VA_ARGS__)
  ------------------
 1149|      0|		return SSH_ERR_NEED_REKEY;
  ------------------
  |  |   63|      0|#define SSH_ERR_NEED_REKEY			-39
  ------------------
 1150|      0|	}
 1151|  1.22k|	return 0;
 1152|  1.22k|}
packet.c:ssh_packet_check_rekey_blocklimit:
 1084|  1.22k|{
 1085|  1.22k|	struct session_state *state = ssh->state;
 1086|  1.22k|	uint32_t out_blocks;
 1087|  1.22k|	const uint64_t max_blocks_in = hard ?
  ------------------
  |  Branch (1087:33): [True: 1.22k, False: 0]
  ------------------
 1088|  1.22k|	    state->hard_max_blocks_in : state->max_blocks_in;
 1089|  1.22k|	const uint64_t max_blocks_out = hard ?
  ------------------
  |  Branch (1089:34): [True: 1.22k, False: 0]
  ------------------
 1090|  1.22k|	    state->hard_max_blocks_out : state->max_blocks_out;
 1091|       |
 1092|       |	/*
 1093|       |	 * Always rekey when MAX_PACKETS sent in either direction
 1094|       |	 * As per RFC4344 section 3.1 we do this after 2^31 packets.
 1095|       |	 */
 1096|  1.22k|	if (state->p_send.packets > MAX_PACKETS ||
  ------------------
  |  | 1075|  2.44k|#define MAX_PACKETS	(1U<<31)
  ------------------
  |  Branch (1096:6): [True: 0, False: 1.22k]
  ------------------
 1097|  1.22k|	    state->p_read.packets > MAX_PACKETS)
  ------------------
  |  | 1075|  1.22k|#define MAX_PACKETS	(1U<<31)
  ------------------
  |  Branch (1097:6): [True: 0, False: 1.22k]
  ------------------
 1098|      0|		return 1;
 1099|       |
 1100|  1.22k|	if (state->newkeys[MODE_OUT] == NULL)
  ------------------
  |  Branch (1100:6): [True: 4, False: 1.22k]
  ------------------
 1101|      4|		return 0;
 1102|       |
 1103|       |	/* Rekey after (cipher-specific) maximum blocks */
 1104|  1.22k|	out_blocks = ROUNDUP(packet_len,
  ------------------
  |  |  270|  1.22k|#define ROUNDUP(x, y)   ((((x)+((y)-1))/(y))*(y))
  ------------------
 1105|  1.22k|	    state->newkeys[MODE_OUT]->enc.block_size);
 1106|  1.22k|	return (max_blocks_out &&
  ------------------
  |  Branch (1106:10): [True: 1.22k, False: 0]
  ------------------
 1107|  1.22k|	    (state->p_send.blocks + out_blocks > max_blocks_out)) ||
  ------------------
  |  Branch (1107:6): [True: 0, False: 1.22k]
  ------------------
 1108|  1.22k|	    (max_blocks_in &&
  ------------------
  |  Branch (1108:7): [True: 1.21k, False: 4]
  ------------------
 1109|  1.21k|	    (state->p_read.blocks > max_blocks_in));
  ------------------
  |  Branch (1109:6): [True: 0, False: 1.21k]
  ------------------
 1110|  1.22k|}
packet.c:ssh_packet_need_rekeying:
 1114|  1.22k|{
 1115|  1.22k|	struct session_state *state = ssh->state;
 1116|       |
 1117|       |	/* Don't attempt rekeying during pre-auth */
 1118|  1.22k|	if (!state->after_authentication)
  ------------------
  |  Branch (1118:6): [True: 1.22k, False: 0]
  ------------------
 1119|  1.22k|		return 0;
 1120|       |
 1121|       |	/* Haven't keyed yet or KEX in progress. */
 1122|      0|	if (ssh_packet_is_rekeying(ssh))
  ------------------
  |  Branch (1122:6): [True: 0, False: 0]
  ------------------
 1123|      0|		return 0;
 1124|       |
 1125|       |	/*
 1126|       |	 * Permit one packet in or out per rekey - this allows us to
 1127|       |	 * make progress when rekey limits are very small.
 1128|       |	 */
 1129|      0|	if (state->p_send.packets == 0 && state->p_read.packets == 0)
  ------------------
  |  Branch (1129:6): [True: 0, False: 0]
  |  Branch (1129:36): [True: 0, False: 0]
  ------------------
 1130|      0|		return 0;
 1131|       |
 1132|       |	/* Time-based rekeying */
 1133|      0|	if (state->rekey_interval != 0 &&
  ------------------
  |  Branch (1133:6): [True: 0, False: 0]
  ------------------
 1134|      0|	    (int64_t)state->rekey_time + state->rekey_interval <= monotime())
  ------------------
  |  Branch (1134:6): [True: 0, False: 0]
  ------------------
 1135|      0|		return 1;
 1136|       |
 1137|      0|	return ssh_packet_check_rekey_blocklimit(ssh, outbound_packet_len, 0);
 1138|      0|}
packet.c:ssh_packet_type_is_kex:
 1394|  1.63k|{
 1395|  1.63k|	return
 1396|  1.63k|	    type >= SSH2_MSG_TRANSPORT_MIN &&
  ------------------
  |  |   65|  3.26k|#define SSH2_MSG_TRANSPORT_MIN				1
  ------------------
  |  Branch (1396:6): [True: 1.63k, False: 0]
  ------------------
 1397|  1.63k|	    type <= SSH2_MSG_TRANSPORT_MAX &&
  ------------------
  |  |   66|  3.26k|#define SSH2_MSG_TRANSPORT_MAX				49
  ------------------
  |  Branch (1397:6): [True: 16, False: 1.61k]
  ------------------
 1398|     16|	    type != SSH2_MSG_SERVICE_REQUEST &&
  ------------------
  |  |   86|  1.64k|#define SSH2_MSG_SERVICE_REQUEST			5
  ------------------
  |  Branch (1398:6): [True: 16, False: 0]
  ------------------
 1399|     16|	    type != SSH2_MSG_SERVICE_ACCEPT &&
  ------------------
  |  |   87|  1.64k|#define SSH2_MSG_SERVICE_ACCEPT				6
  ------------------
  |  Branch (1399:6): [True: 16, False: 0]
  ------------------
 1400|     16|	    type != SSH2_MSG_EXT_INFO;
  ------------------
  |  |   88|     16|#define SSH2_MSG_EXT_INFO				7
  ------------------
  |  Branch (1400:6): [True: 12, False: 4]
  ------------------
 1401|  1.63k|}

LLVMFuzzerTestOneInput:
   20|    516|{
   21|    516|	fuzz_userauth_one(data, size);
   22|    516|	return 0;
   23|    516|}

cleanup_exit:
   74|     36|{
   75|     36|	if (in_fuzz)
  ------------------
  |  Branch (75:6): [True: 36, False: 0]
  ------------------
   76|     36|		longjmp(fuzz_env, code ? code : 1);
  ------------------
  |  Branch (76:21): [True: 36, False: 0]
  ------------------
   77|      0|	_exit(code);
   78|     36|}
__wrap_ssh_packet_write_wait:
   82|    295|{
   83|    295|	(void)ssh;
   84|    295|	return 0;
   85|    295|}
mm_is_monitor:
   91|    295|{
   92|    295|	return 0;
   93|    295|}
mm_getpwnamallow:
   97|    331|{
   98|    331|	(void)ssh;
   99|    331|	(void)user;
  100|    331|	return &g_fake_pw;
  101|    331|}
mm_auth_password:
  105|      1|{
  106|      1|	(void)ssh;
  107|      1|	(void)password;
  108|      1|	return 0;
  109|      1|}
mm_inform_authserv:
  146|    331|{
  147|    331|	(void)service;
  148|    331|	(void)style;
  149|    331|}
fuzz_userauth_one:
  357|    516|{
  358|    516|	if (init_once() != 0)
  ------------------
  |  Branch (358:6): [True: 0, False: 516]
  ------------------
  359|      0|		return;
  360|    516|	if (size > 65000)
  ------------------
  |  Branch (360:6): [True: 3, False: 513]
  ------------------
  361|      3|		return;
  362|       |
  363|    513|	fuzz_reset_authctxt(g_server);
  364|       |
  365|    513|	in_fuzz = 1;
  366|    513|	if (setjmp(fuzz_env) == 0) {
  ------------------
  |  Branch (366:6): [True: 513, False: 0]
  ------------------
  367|    513|		size_t transferred;
  368|    513|		if (ssh_packet_put(g_client, SSH2_MSG_USERAUTH_REQUEST,
  ------------------
  |  |  118|    513|#define SSH2_MSG_USERAUTH_REQUEST			50
  ------------------
  |  Branch (368:7): [True: 0, False: 513]
  ------------------
  369|    513|		    data, size) != 0)
  370|      0|			goto done;
  371|    513|		if (pump(g_client, g_server, &transferred) != 0)
  ------------------
  |  Branch (371:7): [True: 0, False: 513]
  ------------------
  372|      0|			goto done;
  373|    513|		(void)ssh_dispatch_run(g_server, DISPATCH_NONBLOCK, NULL);
  374|    513|	done:
  375|    477|		;
  376|    477|	}
  377|    477|	in_fuzz = 0;
  378|    477|}
sshd_auth_session_fuzz_helper.c:init_once:
  284|    516|{
  285|    516|	if (g_init)
  ------------------
  |  Branch (285:6): [True: 515, False: 1]
  ------------------
  286|    515|		return 0;
  287|      1|	signal(SIGPIPE, SIG_IGN);
  288|      1|	log_init("sshd_auth_session_fuzz", SYSLOG_LEVEL_ERROR,
  289|      1|	    SYSLOG_FACILITY_AUTH, 0);
  290|       |
  291|      1|	memset(&g_fake_pw, 0, sizeof(g_fake_pw));
  292|      1|	g_fake_pw.pw_name = (char *)"fuzz";
  293|      1|	g_fake_pw.pw_uid = 1000;
  294|      1|	g_fake_pw.pw_gid = 1000;
  295|      1|	g_fake_pw.pw_dir = (char *)"/tmp";
  296|      1|	g_fake_pw.pw_shell = (char *)"/bin/sh";
  297|      1|	privsep_pw = &g_fake_pw;
  298|       |
  299|      1|	initialize_server_options(&options);
  300|      1|	fill_default_server_options(&options);
  301|      1|	options.password_authentication = 1;
  302|      1|	options.pubkey_authentication = 1;
  303|      1|	options.kbd_interactive_authentication = 1;
  304|      1|	options.hostbased_authentication = 1;
  305|      1|	options.max_authtries = 1024;
  306|       |
  307|      1|	loginmsg = sshbuf_new();
  308|       |
  309|      1|	struct sshkey *priv = load_private(PRIV_ED25519);
  ------------------
  |  |   50|      1|#define PRIV_ED25519 \
  |  |   51|      1|"-----BEGIN OPENSSH PRIVATE KEY-----\n"\
  |  |   52|      1|"b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW\n"\
  |  |   53|      1|"QyNTUxOQAAACAz0F5hFTFS5nhUcmnyjFVoDw5L/P7kQU8JnBA2rWczAwAAAIhWlP99VpT/\n"\
  |  |   54|      1|"fQAAAAtzc2gtZWQyNTUxOQAAACAz0F5hFTFS5nhUcmnyjFVoDw5L/P7kQU8JnBA2rWczAw\n"\
  |  |   55|      1|"AAAEDE1rlcMC0s0X3TKVZAOVavZOywwkXw8tO5dLObxaCMEDPQXmEVMVLmeFRyafKMVWgP\n"\
  |  |   56|      1|"Dkv8/uRBTwmcEDatZzMDAAAAAAECAwQF\n"\
  |  |   57|      1|"-----END OPENSSH PRIVATE KEY-----\n"
  ------------------
  310|      1|	struct sshkey *pub = load_public(PUB_ED25519);
  ------------------
  |  |   58|      1|#define PUB_ED25519 \
  |  |   59|      1|"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDPQXmEVMVLmeFRyafKMVWgPDkv8/uRBTwmcEDatZzMD"
  ------------------
  311|      1|	char *keyname = xstrdup(sshkey_ssh_name(priv));
  312|       |
  313|      1|	const char *defaults[PROPOSAL_MAX] = { KEX_CLIENT };
  ------------------
  |  |  103|      1|	KEX_CLIENT_KEX, \
  |  |  ------------------
  |  |  |  |   37|      1|#define KEX_CLIENT_KEX KEX_SERVER_KEX "," \
  |  |  |  |  ------------------
  |  |  |  |  |  |   28|      1|	"mlkem768x25519-sha256," \
  |  |  |  |  |  |   29|      1|	"sntrup761x25519-sha512," \
  |  |  |  |  |  |   30|      1|	"sntrup761x25519-sha512@openssh.com," \
  |  |  |  |  |  |   31|      1|	"curve25519-sha256," \
  |  |  |  |  |  |   32|      1|	"curve25519-sha256@libssh.org," \
  |  |  |  |  |  |   33|      1|	"ecdh-sha2-nistp256," \
  |  |  |  |  |  |   34|      1|	"ecdh-sha2-nistp384," \
  |  |  |  |  |  |   35|      1|	"ecdh-sha2-nistp521" \
  |  |  |  |  ------------------
  |  |  |  |   38|      1|	"diffie-hellman-group-exchange-sha256," \
  |  |  |  |   39|      1|	"diffie-hellman-group16-sha512," \
  |  |  |  |   40|      1|	"diffie-hellman-group18-sha512," \
  |  |  |  |   41|      1|	"diffie-hellman-group14-sha256"
  |  |  ------------------
  |  |  104|      1|	KEX_DEFAULT_PK_ALG, \
  |  |  ------------------
  |  |  |  |   44|      1|	"ssh-ed25519-cert-v01@openssh.com," \
  |  |  |  |   45|      1|	"ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |  |  |   46|      1|	"ecdsa-sha2-nistp384-cert-v01@openssh.com," \
  |  |  |  |   47|      1|	"ecdsa-sha2-nistp521-cert-v01@openssh.com," \
  |  |  |  |   48|      1|	"sk-ssh-ed25519-cert-v01@openssh.com," \
  |  |  |  |   49|      1|	"sk-ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |  |  |   50|      1|	"webauthn-sk-ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |  |  |   51|      1|	"rsa-sha2-512-cert-v01@openssh.com," \
  |  |  |  |   52|      1|	"rsa-sha2-256-cert-v01@openssh.com," \
  |  |  |  |   53|      1|	"ssh-mldsa44-ed25519-cert," \
  |  |  |  |   54|      1|	"ssh-ed25519," \
  |  |  |  |   55|      1|	"ecdsa-sha2-nistp256," \
  |  |  |  |   56|      1|	"ecdsa-sha2-nistp384," \
  |  |  |  |   57|      1|	"ecdsa-sha2-nistp521," \
  |  |  |  |   58|      1|	"sk-ssh-ed25519@openssh.com," \
  |  |  |  |   59|      1|	"sk-ecdsa-sha2-nistp256@openssh.com," \
  |  |  |  |   60|      1|	"webauthn-sk-ecdsa-sha2-nistp256@openssh.com," \
  |  |  |  |   61|      1|	"rsa-sha2-512," \
  |  |  |  |   62|      1|	"rsa-sha2-256," \
  |  |  |  |   63|      1|	"ssh-mldsa44-ed25519"
  |  |  ------------------
  |  |  105|      1|	KEX_CLIENT_ENCRYPT, \
  |  |  ------------------
  |  |  |  |   70|      1|#define KEX_CLIENT_ENCRYPT KEX_SERVER_ENCRYPT
  |  |  |  |  ------------------
  |  |  |  |  |  |   66|      1|	"chacha20-poly1305@openssh.com," \
  |  |  |  |  |  |   67|      1|	"aes128-gcm@openssh.com,aes256-gcm@openssh.com," \
  |  |  |  |  |  |   68|      1|	"aes128-ctr,aes192-ctr,aes256-ctr"
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  106|      1|	KEX_CLIENT_ENCRYPT, \
  |  |  ------------------
  |  |  |  |   70|      1|#define KEX_CLIENT_ENCRYPT KEX_SERVER_ENCRYPT
  |  |  |  |  ------------------
  |  |  |  |  |  |   66|      1|	"chacha20-poly1305@openssh.com," \
  |  |  |  |  |  |   67|      1|	"aes128-gcm@openssh.com,aes256-gcm@openssh.com," \
  |  |  |  |  |  |   68|      1|	"aes128-ctr,aes192-ctr,aes256-ctr"
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      1|	KEX_CLIENT_MAC, \
  |  |  ------------------
  |  |  |  |   84|      1|#define KEX_CLIENT_MAC KEX_SERVER_MAC
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|      1|	"umac-64-etm@openssh.com," \
  |  |  |  |  |  |   74|      1|	"umac-128-etm@openssh.com," \
  |  |  |  |  |  |   75|      1|	"hmac-sha2-256-etm@openssh.com," \
  |  |  |  |  |  |   76|      1|	"hmac-sha2-512-etm@openssh.com," \
  |  |  |  |  |  |   77|      1|	"hmac-sha1-etm@openssh.com," \
  |  |  |  |  |  |   78|      1|	"umac-64@openssh.com," \
  |  |  |  |  |  |   79|      1|	"umac-128@openssh.com," \
  |  |  |  |  |  |   80|      1|	"hmac-sha2-256," \
  |  |  |  |  |  |   81|      1|	"hmac-sha2-512," \
  |  |  |  |  |  |   82|      1|	"hmac-sha1"
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|      1|	KEX_CLIENT_MAC, \
  |  |  ------------------
  |  |  |  |   84|      1|#define KEX_CLIENT_MAC KEX_SERVER_MAC
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|      1|	"umac-64-etm@openssh.com," \
  |  |  |  |  |  |   74|      1|	"umac-128-etm@openssh.com," \
  |  |  |  |  |  |   75|      1|	"hmac-sha2-256-etm@openssh.com," \
  |  |  |  |  |  |   76|      1|	"hmac-sha2-512-etm@openssh.com," \
  |  |  |  |  |  |   77|      1|	"hmac-sha1-etm@openssh.com," \
  |  |  |  |  |  |   78|      1|	"umac-64@openssh.com," \
  |  |  |  |  |  |   79|      1|	"umac-128@openssh.com," \
  |  |  |  |  |  |   80|      1|	"hmac-sha2-256," \
  |  |  |  |  |  |   81|      1|	"hmac-sha2-512," \
  |  |  |  |  |  |   82|      1|	"hmac-sha1"
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  109|      1|	KEX_DEFAULT_COMP, \
  |  |  ------------------
  |  |  |  |   99|      1|#define	KEX_DEFAULT_COMP	"none,zlib@openssh.com"
  |  |  ------------------
  |  |  110|      1|	KEX_DEFAULT_COMP, \
  |  |  ------------------
  |  |  |  |   99|      1|#define	KEX_DEFAULT_COMP	"none,zlib@openssh.com"
  |  |  ------------------
  |  |  111|      1|	KEX_DEFAULT_LANG, \
  |  |  ------------------
  |  |  |  |  100|      1|#define	KEX_DEFAULT_LANG	""
  |  |  ------------------
  |  |  112|      1|	KEX_DEFAULT_LANG
  |  |  ------------------
  |  |  |  |  100|      1|#define	KEX_DEFAULT_LANG	""
  |  |  ------------------
  ------------------
  314|      1|	char *proposal[PROPOSAL_MAX] = { 0 };
  315|      1|	int i;
  316|     11|	for (i = 0; i < PROPOSAL_MAX; i++) {
  ------------------
  |  Branch (316:14): [True: 10, False: 1]
  ------------------
  317|     10|		const char *p = defaults[i];
  318|     10|		if (i == PROPOSAL_SERVER_HOST_KEY_ALGS)
  ------------------
  |  Branch (318:7): [True: 1, False: 9]
  ------------------
  319|      1|			p = keyname;
  320|      9|		else if (i == PROPOSAL_KEX_ALGS)
  ------------------
  |  Branch (320:12): [True: 1, False: 8]
  ------------------
  321|      1|			p = "curve25519-sha256";
  322|      8|		else if (i == PROPOSAL_ENC_ALGS_CTOS ||
  ------------------
  |  Branch (322:12): [True: 1, False: 7]
  ------------------
  323|      7|		    i == PROPOSAL_ENC_ALGS_STOC)
  ------------------
  |  Branch (323:7): [True: 1, False: 6]
  ------------------
  324|      2|			p = "aes128-ctr";
  325|      6|		else if (i == PROPOSAL_MAC_ALGS_CTOS ||
  ------------------
  |  Branch (325:12): [True: 1, False: 5]
  ------------------
  326|      5|		    i == PROPOSAL_MAC_ALGS_STOC)
  ------------------
  |  Branch (326:7): [True: 1, False: 4]
  ------------------
  327|      2|			p = "hmac-sha2-256";
  328|     10|		proposal[i] = strdup(p);
  329|     10|	}
  330|      1|	struct kex_params kp;
  331|      1|	memcpy(kp.proposal, proposal, sizeof(proposal));
  332|       |
  333|      1|	if (ssh_init(&g_client, 0, &kp) != 0 ||
  ------------------
  |  Branch (333:6): [True: 0, False: 1]
  ------------------
  334|      1|	    ssh_init(&g_server, 1, &kp) != 0)
  ------------------
  |  Branch (334:6): [True: 0, False: 1]
  ------------------
  335|      0|		return -1;
  336|      1|	if (ssh_add_hostkey(g_server, priv) != 0 ||
  ------------------
  |  Branch (336:6): [True: 0, False: 1]
  ------------------
  337|      1|	    ssh_add_hostkey(g_client, pub) != 0)
  ------------------
  |  Branch (337:6): [True: 0, False: 1]
  ------------------
  338|      0|		return -1;
  339|      1|	if (run_kex(g_client, g_server) != 0)
  ------------------
  |  Branch (339:6): [True: 0, False: 1]
  ------------------
  340|      0|		return -1;
  341|       |
  342|      1|	fuzz_reset_authctxt(g_server);
  343|       |
  344|      1|	ssh_dispatch_init(g_server, &dispatch_protocol_ignore);
  345|      1|	ssh_dispatch_set(g_server, SSH2_MSG_USERAUTH_REQUEST,
  ------------------
  |  |  118|      1|#define SSH2_MSG_USERAUTH_REQUEST			50
  ------------------
  346|      1|	    &input_userauth_request);
  347|       |
  348|      1|	free(keyname);
  349|     11|	for (i = 0; i < PROPOSAL_MAX; i++)
  ------------------
  |  Branch (349:14): [True: 10, False: 1]
  ------------------
  350|     10|		free(proposal[i]);
  351|      1|	g_init = 1;
  352|      1|	return 0;
  353|      1|}
sshd_auth_session_fuzz_helper.c:load_private:
  172|      1|{
  173|      1|	struct sshbuf *b = sshbuf_from(str, strlen(str));
  174|      1|	struct sshkey *k = NULL;
  175|      1|	if (b == NULL || sshkey_parse_private_fileblob(b, "", &k, NULL) != 0)
  ------------------
  |  Branch (175:6): [True: 0, False: 1]
  |  Branch (175:19): [True: 0, False: 1]
  ------------------
  176|      0|		abort();
  177|      1|	sshbuf_free(b);
  178|      1|	return k;
  179|      1|}
sshd_auth_session_fuzz_helper.c:load_public:
  183|      1|{
  184|      1|	char *tmp, *cp;
  185|      1|	struct sshkey *k = sshkey_new(KEY_UNSPEC);
  186|      1|	if (k == NULL)
  ------------------
  |  Branch (186:6): [True: 0, False: 1]
  ------------------
  187|      0|		abort();
  188|      1|	tmp = cp = strdup(str);
  189|      1|	if (sshkey_read(k, &cp) != 0)
  ------------------
  |  Branch (189:6): [True: 0, False: 1]
  ------------------
  190|      0|		abort();
  191|      1|	free(tmp);
  192|      1|	return k;
  193|      1|}
sshd_auth_session_fuzz_helper.c:run_kex:
  218|      1|{
  219|      1|	int r;
  220|      1|	size_t cn, sn;
  221|      4|	for (int i = 0; i < 100; i++) {
  ------------------
  |  Branch (221:18): [True: 4, False: 0]
  ------------------
  222|      4|		if ((r = pump(server, client, &sn)) != 0) return r;
  ------------------
  |  Branch (222:7): [True: 0, False: 4]
  ------------------
  223|      4|		if ((r = pump(client, server, &cn)) != 0) return r;
  ------------------
  |  Branch (223:7): [True: 0, False: 4]
  ------------------
  224|      4|		if (server->kex->done && client->kex->done)
  ------------------
  |  Branch (224:7): [True: 1, False: 3]
  |  Branch (224:28): [True: 1, False: 0]
  ------------------
  225|      1|			return 0;
  226|      3|		if (cn == 0 && sn == 0)
  ------------------
  |  Branch (226:7): [True: 0, False: 3]
  |  Branch (226:18): [True: 0, False: 0]
  ------------------
  227|      0|			return SSH_ERR_PROTOCOL_ERROR;
  ------------------
  |  |   79|      0|#define SSH_ERR_PROTOCOL_ERROR			-55
  ------------------
  228|      3|	}
  229|      0|	return SSH_ERR_PROTOCOL_ERROR;
  ------------------
  |  |   79|      0|#define SSH_ERR_PROTOCOL_ERROR			-55
  ------------------
  230|      1|}
sshd_auth_session_fuzz_helper.c:fuzz_reset_authctxt:
  261|    514|{
  262|    514|	unsigned int i;
  263|       |
  264|    514|	free(g_authctxt.user);
  265|    514|	free(g_authctxt.service);
  266|    514|	free(g_authctxt.style);
  267|    514|	free(g_authctxt.auth_method_info);
  268|    514|	if (g_authctxt.auth_methods != NULL) {
  ------------------
  |  Branch (268:6): [True: 0, False: 514]
  ------------------
  269|      0|		for (i = 0; i < g_authctxt.num_auth_methods; i++)
  ------------------
  |  Branch (269:15): [True: 0, False: 0]
  ------------------
  270|      0|			free(g_authctxt.auth_methods[i]);
  271|      0|		free(g_authctxt.auth_methods);
  272|      0|	}
  273|    514|	sshkey_free(g_authctxt.auth_method_key);
  274|    514|	for (i = 0; i < g_authctxt.nprev_keys; i++)
  ------------------
  |  Branch (274:14): [True: 0, False: 514]
  ------------------
  275|      0|		sshkey_free(g_authctxt.prev_keys[i]);
  276|    514|	free(g_authctxt.prev_keys);
  277|    514|	sshbuf_free(g_authctxt.session_info);
  278|    514|	memset(&g_authctxt, 0, sizeof(g_authctxt));
  279|    514|	ssh->authctxt = &g_authctxt;
  280|    514|}
sshd_auth_session_fuzz_helper.c:pump:
  197|    521|{
  198|    521|	const u_char *buf;
  199|    521|	size_t len;
  200|    521|	u_char type;
  201|    521|	int r;
  202|    521|	*transferred = 0;
  203|    521|	if ((r = ssh_packet_next(from, &type)) != 0)
  ------------------
  |  Branch (203:6): [True: 0, False: 521]
  ------------------
  204|      0|		return r;
  205|    521|	buf = ssh_output_ptr(from, &len);
  206|    521|	if (len == 0)
  ------------------
  |  Branch (206:6): [True: 2, False: 519]
  ------------------
  207|      2|		return 0;
  208|    519|	if ((r = ssh_input_append(to, buf, len)) != 0)
  ------------------
  |  Branch (208:6): [True: 0, False: 519]
  ------------------
  209|      0|		return r;
  210|    519|	if ((r = ssh_output_consume(from, len)) != 0)
  ------------------
  |  Branch (210:6): [True: 0, False: 519]
  ------------------
  211|      0|		return r;
  212|    519|	*transferred = len;
  213|    519|	return 0;
  214|    519|}

initialize_server_options:
   86|      1|{
   87|      1|	memset(options, 0, sizeof(*options));
   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
   91|      1|#define SSHCONF_STRARRAY(var, nvar, conf, flags, cp) \
   92|      1|	options->nvar = 0; \
   93|      1|	options->var = NULL;
   94|      1|#define SSHCONF_CUSTOM(conf, funcsuffix, flags, cp) \
   95|      1|	init_##funcsuffix(options)
   96|      1|#define SSHCONF_NONCONF(funcsuffix) \
   97|      1|	init_##funcsuffix(options)
   98|      1|#define SSHCONF_DEPRECATE(conf, flags, opcode)		/* empty */
   99|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  100|      1|#define SSHCONF_UNSUPPORTED_STRING(var, conf, flags)	options->var = NULL;
  101|      1|#define SSHCONF_ALIAS(old, conf, flags)			/* empty */
  102|       |
  103|       |	/* Using macros for these is a bit overkill but forces consistency */
  104|      1|#define init_hostkeyfile(options) \
  105|      1|	options->host_key_files = 0; \
  106|      1|	options->num_host_key_files = 0; \
  107|      1|	options->host_key_file_userprovided = NULL;
  108|      1|#define init_ipqos(options) \
  109|      1|	options->ip_qos_interactive = -1; \
  110|      1|	options->ip_qos_bulk = -1;
  111|      1|#define init_listenaddress(options) \
  112|      1|	options->queued_listen_addrs = NULL; \
  113|      1|	options->num_queued_listens = 0; \
  114|      1|	options->listen_addrs = NULL; \
  115|      1|	options->num_listen_addrs = 0;
  116|      1|#define init_logfacility(options) \
  117|      1|	options->log_facility = SYSLOG_FACILITY_NOT_SET;
  118|      1|#define init_loglevel(options) \
  119|      1|	options->log_level = SYSLOG_LEVEL_NOT_SET;
  120|      1|#define init_port(options) \
  121|      1|	options->num_ports = 0; \
  122|      1|	options->ports_from_cmdline = 0;
  123|      1|#define init_gatewayports(options) \
  124|      1|	options->fwd_opts.gateway_ports = -1;
  125|      1|#define init_streamlocalbindmask(options) \
  126|      1|	options->fwd_opts.streamlocal_bind_mask = (mode_t)-1;
  127|      1|#define init_streamlocalbindunlink(options) \
  128|      1|	options->fwd_opts.streamlocal_bind_unlink = -1;
  129|      1|#define init_maxstartups(options) \
  130|      1|	options->max_startups_begin = -1; \
  131|      1|	options->max_startups_rate = -1; \
  132|      1|	options->max_startups = -1;
  133|      1|#define init_permituserenv(options) \
  134|      1|	options->permit_user_env = -1; \
  135|      1|	options->permit_user_env_allowlist = NULL;
  136|      1|#define init_persourcenetblocksize(options) \
  137|      1|	options->per_source_masklen_ipv4 = -1; \
  138|      1|	options->per_source_masklen_ipv6 = -1;
  139|      1|#define init_persourcepenalties(options) \
  140|      1|	options->per_source_penalty_exempt = NULL; \
  141|      1|	options->per_source_penalty.enabled = -1; \
  142|      1|	options->per_source_penalty.max_sources4 = -1; \
  143|      1|	options->per_source_penalty.max_sources6 = -1; \
  144|      1|	options->per_source_penalty.overflow_mode = -1; \
  145|      1|	options->per_source_penalty.overflow_mode6 = -1; \
  146|      1|	options->per_source_penalty.penalty_crash = -1.0; \
  147|      1|	options->per_source_penalty.penalty_authfail = -1.0; \
  148|      1|	options->per_source_penalty.penalty_invaliduser = -1.0; \
  149|      1|	options->per_source_penalty.penalty_noauth = -1.0; \
  150|      1|	options->per_source_penalty.penalty_grace = -1.0; \
  151|      1|	options->per_source_penalty.penalty_refuseconnection = -1.0; \
  152|      1|	options->per_source_penalty.penalty_max = -1.0; \
  153|      1|	options->per_source_penalty.penalty_min = -1.0;
  154|      1|#define init_rekeylimit(options) \
  155|      1|	options->rekey_limit = -1; \
  156|      1|	options->rekey_interval = -1;
  157|      1|#define init_subsystem(options) \
  158|      1|	options->num_subsystems = 0; \
  159|      1|	options->subsystem_name = NULL; \
  160|      1|	options->subsystem_command = NULL; \
  161|      1|	options->subsystem_args = NULL;
  162|      1|#define init_pubkey_auth_options(options) \
  163|      1|	options->pubkey_auth_options = -1; \
  164|      1|	options->max_pubkey_ok = -1;
  165|      1|#define init_timingsecret(options) \
  166|      1|	options->timing_secret = 0;
  167|       |
  168|      1|	SSHD_CONFIG_ENTRIES
  ------------------
  |  |  337|      1|	SSHD_CONFIG_ENTRIES_BASE \
  |  |  ------------------
  |  |  |  |  273|      1|	SSHD_CONFIG_ENTRIES_CUSTOM \
  |  |  |  |  ------------------
  |  |  |  |  |  |  148|      1|#define SSHD_CONFIG_ENTRIES_CUSTOM \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  121|      1|	options->num_ports = 0; \
  |  |  |  |  |  |  |  |  |  |  122|      1|	options->ports_from_cmdline = 0;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      1|SSHCONF_CUSTOM(Port, port, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  112|      1|	options->queued_listen_addrs = NULL; \
  |  |  |  |  |  |  |  |  |  |  113|      1|	options->num_queued_listens = 0; \
  |  |  |  |  |  |  |  |  |  |  114|      1|	options->listen_addrs = NULL; \
  |  |  |  |  |  |  |  |  |  |  115|      1|	options->num_listen_addrs = 0;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  150|      1|SSHCONF_CUSTOM(ListenAddress, listenaddress, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  105|      1|	options->host_key_files = 0; \
  |  |  |  |  |  |  |  |  |  |  106|      1|	options->num_host_key_files = 0; \
  |  |  |  |  |  |  |  |  |  |  107|      1|	options->host_key_file_userprovided = NULL;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  151|      1|SSHCONF_CUSTOM(HostKey, hostkeyfile, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  109|      1|	options->ip_qos_interactive = -1; \
  |  |  |  |  |  |  |  |  |  |  110|      1|	options->ip_qos_bulk = -1;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  152|      1|SSHCONF_CUSTOM(IPQoS, ipqos, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  124|      1|	options->fwd_opts.gateway_ports = -1;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  153|      1|SSHCONF_CUSTOM(GatewayPorts, gatewayports, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  126|      1|	options->fwd_opts.streamlocal_bind_mask = (mode_t)-1;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|SSHCONF_CUSTOM(StreamLocalBindMask, streamlocalbindmask, SSHCFG_ALL, SSHCFG_COPY_MANUAL) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  128|      1|	options->fwd_opts.streamlocal_bind_unlink = -1;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|SSHCONF_CUSTOM(StreamLocalBindUnlink, streamlocalbindunlink, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  117|      1|	options->log_facility = SYSLOG_FACILITY_NOT_SET;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|SSHCONF_CUSTOM(SyslogFacility, logfacility, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  119|      1|	options->log_level = SYSLOG_LEVEL_NOT_SET;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|SSHCONF_CUSTOM(LogLevel, loglevel, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  134|      1|	options->permit_user_env = -1; \
  |  |  |  |  |  |  |  |  |  |  135|      1|	options->permit_user_env_allowlist = NULL;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      1|SSHCONF_CUSTOM(PermitUserEnvironment, permituserenv, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  158|      1|	options->num_subsystems = 0; \
  |  |  |  |  |  |  |  |  |  |  159|      1|	options->subsystem_name = NULL; \
  |  |  |  |  |  |  |  |  |  |  160|      1|	options->subsystem_command = NULL; \
  |  |  |  |  |  |  |  |  |  |  161|      1|	options->subsystem_args = NULL;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  159|      1|SSHCONF_CUSTOM(Subsystem, subsystem, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  130|      1|	options->max_startups_begin = -1; \
  |  |  |  |  |  |  |  |  |  |  131|      1|	options->max_startups_rate = -1; \
  |  |  |  |  |  |  |  |  |  |  132|      1|	options->max_startups = -1;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  160|      1|SSHCONF_CUSTOM(MaxStartups, maxstartups, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  137|      1|	options->per_source_masklen_ipv4 = -1; \
  |  |  |  |  |  |  |  |  |  |  138|      1|	options->per_source_masklen_ipv6 = -1;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  161|      1|SSHCONF_CUSTOM(PerSourceNetBlockSize, persourcenetblocksize, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  140|      1|	options->per_source_penalty_exempt = NULL; \
  |  |  |  |  |  |  |  |  |  |  141|      1|	options->per_source_penalty.enabled = -1; \
  |  |  |  |  |  |  |  |  |  |  142|      1|	options->per_source_penalty.max_sources4 = -1; \
  |  |  |  |  |  |  |  |  |  |  143|      1|	options->per_source_penalty.max_sources6 = -1; \
  |  |  |  |  |  |  |  |  |  |  144|      1|	options->per_source_penalty.overflow_mode = -1; \
  |  |  |  |  |  |  |  |  |  |  145|      1|	options->per_source_penalty.overflow_mode6 = -1; \
  |  |  |  |  |  |  |  |  |  |  146|      1|	options->per_source_penalty.penalty_crash = -1.0; \
  |  |  |  |  |  |  |  |  |  |  147|      1|	options->per_source_penalty.penalty_authfail = -1.0; \
  |  |  |  |  |  |  |  |  |  |  148|      1|	options->per_source_penalty.penalty_invaliduser = -1.0; \
  |  |  |  |  |  |  |  |  |  |  149|      1|	options->per_source_penalty.penalty_noauth = -1.0; \
  |  |  |  |  |  |  |  |  |  |  150|      1|	options->per_source_penalty.penalty_grace = -1.0; \
  |  |  |  |  |  |  |  |  |  |  151|      1|	options->per_source_penalty.penalty_refuseconnection = -1.0; \
  |  |  |  |  |  |  |  |  |  |  152|      1|	options->per_source_penalty.penalty_max = -1.0; \
  |  |  |  |  |  |  |  |  |  |  153|      1|	options->per_source_penalty.penalty_min = -1.0;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  162|      1|SSHCONF_CUSTOM(PerSourcePenalties, persourcepenalties, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      1|	options->rekey_limit = -1; \
  |  |  |  |  |  |  |  |  |  |  156|      1|	options->rekey_interval = -1;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  163|      1|SSHCONF_CUSTOM(RekeyLimit, rekeylimit, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   95|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  163|      1|	options->pubkey_auth_options = -1; \
  |  |  |  |  |  |  |  |  |  |  164|      1|	options->max_pubkey_ok = -1;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  164|      1|SSHCONF_CUSTOM(PubkeyAuthOptions, pubkey_auth_options, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   97|      1|	init_##funcsuffix(options)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  166|      1|	options->timing_secret = 0;
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  165|      1|SSHCONF_NONCONF(timingsecret)
  |  |  |  |  ------------------
  |  |  |  |  274|      1|	SSHD_CONFIG_ENTRIES_MAIN \
  |  |  |  |  ------------------
  |  |  |  |  |  |  167|      1|#define SSHD_CONFIG_ENTRIES_MAIN \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  168|      1|SSHCONF_INT(address_family, AddressFamily, SSHCFG_GLOBAL, multistate_addressfamily, AF_UNSPEC, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      1|SSHCONF_STRING(routing_domain, RDomain, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      1|	options->nvar = 0; \
  |  |  |  |  |  |  |  |   93|      1|	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  170|      1|SSHCONF_STRARRAY(host_cert_files, num_host_cert_files, HostCertificate, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      1|SSHCONF_STRING(host_key_agent, HostKeyAgent, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  172|      1|SSHCONF_STRING(pid_file, PidFile, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      1|SSHCONF_STRING(moduli_file, ModuliFile, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  174|      1|SSHCONF_INT(login_grace_time, LoginGraceTime, SSHCFG_GLOBAL, NULL, SSHD_DEFAULT_LOGIN_GRACE_TIME, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      1|SSHCONF_INT(permit_root_login, PermitRootLogin, SSHCFG_ALL, multistate_permitrootlogin, PERMIT_NO_PASSWD, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  176|      1|SSHCONF_INT(ignore_rhosts, IgnoreRhosts, SSHCFG_ALL, multistate_ignore_rhosts, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  177|      1|SSHCONF_INTFLAG(ignore_user_known_hosts, IgnoreUserKnownHosts, SSHCFG_GLOBAL, 0, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|      1|SSHCONF_INTFLAG(print_motd, PrintMotd, SSHCFG_GLOBAL, 1, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  179|      1|SSHCONF_INTFLAG(x11_forwarding, X11Forwarding, SSHCFG_ALL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|      1|SSHCONF_INT(x11_display_offset, X11DisplayOffset, SSHCFG_ALL, NULL, SSHD_DEFAULT_X11_DISPLAY_OFFSET, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|SSHCONF_INTFLAG(x11_use_localhost, X11UseLocalhost, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      1|SSHCONF_STRING(xauth_location, XAuthLocation, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  183|      1|SSHCONF_INTFLAG(permit_tty, PermitTTY, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      1|SSHCONF_INTFLAG(permit_user_rc, PermitUserRC, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  185|      1|SSHCONF_INTFLAG(strict_modes, StrictModes, SSHCFG_GLOBAL, 1, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  186|      1|SSHCONF_INTFLAG(tcp_keep_alive, TCPKeepAlive, SSHCFG_GLOBAL, SSH_KEEPALIVES_TRANSPORT, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  187|      1|SSHCONF_STRING(ciphers, Ciphers, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  188|      1|SSHCONF_STRING(macs, Macs, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  189|      1|SSHCONF_STRING(kex_algorithms, KexAlgorithms, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      1|	options->nvar = 0; \
  |  |  |  |  |  |  |  |   93|      1|	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  190|      1|SSHCONF_STRARRAY(log_verbose, num_log_verbose, LogVerbose, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  191|      1|SSHCONF_INTFLAG(hostbased_authentication, HostbasedAuthentication, SSHCFG_ALL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  192|      1|SSHCONF_INTFLAG(hostbased_uses_name_from_packet_only, HostbasedUsesNameFromPacketOnly, SSHCFG_ALL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  193|      1|SSHCONF_STRING(hostbased_accepted_algos, HostbasedAcceptedAlgorithms, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  194|      1|SSHCONF_STRING(hostkeyalgorithms, HostKeyAlgorithms, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  195|      1|SSHCONF_STRING(ca_sign_algorithms, CASignatureAlgorithms, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  196|      1|SSHCONF_INTFLAG(pubkey_authentication, PubkeyAuthentication, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  197|      1|SSHCONF_STRING(pubkey_accepted_algos, PubkeyAcceptedAlgorithms, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  198|      1|SSHCONF_INTFLAG(password_authentication, PasswordAuthentication, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  199|      1|SSHCONF_INTFLAG(kbd_interactive_authentication, KbdInteractiveAuthentication, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  200|      1|SSHCONF_INTFLAG(permit_empty_passwd, PermitEmptyPasswords, SSHCFG_ALL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  201|      1|SSHCONF_INT(compression, Compression, SSHCFG_GLOBAL, multistate_compression, SSHD_DEFAULT_COMPRESSION, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  202|      1|SSHCONF_INT(allow_tcp_forwarding, AllowTcpForwarding, SSHCFG_ALL, multistate_tcpfwd, FORWARD_ALLOW, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  203|      1|SSHCONF_INT(allow_streamlocal_forwarding, AllowStreamLocalForwarding, SSHCFG_ALL, multistate_tcpfwd, FORWARD_ALLOW, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  204|      1|SSHCONF_INTFLAG(allow_agent_forwarding, AllowAgentForwarding, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  205|      1|SSHCONF_INTFLAG(disable_forwarding, DisableForwarding, SSHCFG_ALL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      1|	options->nvar = 0; \
  |  |  |  |  |  |  |  |   93|      1|	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|SSHCONF_STRARRAY(allow_users, num_allow_users, AllowUsers, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      1|	options->nvar = 0; \
  |  |  |  |  |  |  |  |   93|      1|	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  207|      1|SSHCONF_STRARRAY(deny_users, num_deny_users, DenyUsers, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      1|	options->nvar = 0; \
  |  |  |  |  |  |  |  |   93|      1|	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  208|      1|SSHCONF_STRARRAY(allow_groups, num_allow_groups, AllowGroups, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      1|	options->nvar = 0; \
  |  |  |  |  |  |  |  |   93|      1|	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  209|      1|SSHCONF_STRARRAY(deny_groups, num_deny_groups, DenyGroups, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      1|	options->nvar = 0; \
  |  |  |  |  |  |  |  |   93|      1|	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      1|SSHCONF_STRARRAY(accept_env, num_accept_env, AcceptEnv, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      1|	options->nvar = 0; \
  |  |  |  |  |  |  |  |   93|      1|	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  211|      1|SSHCONF_STRARRAY(setenv, num_setenv, SetEnv, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  212|      1|SSHCONF_INT(per_source_max_startups, PerSourceMaxStartups, SSHCFG_GLOBAL, NULL, INT_MAX, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  213|      1|SSHCONF_STRING(per_source_penalty_exempt, PerSourcePenaltyExemptList, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  214|      1|SSHCONF_INT(max_authtries, MaxAuthTries, SSHCFG_ALL, NULL, DEFAULT_AUTH_FAIL_MAX, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  215|      1|SSHCONF_INT(max_sessions, MaxSessions, SSHCFG_ALL, NULL, DEFAULT_SESSIONS_MAX, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  216|      1|SSHCONF_STRING(banner, Banner, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      1|SSHCONF_INTFLAG(use_dns, UseDNS, SSHCFG_GLOBAL, 0, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  218|      1|SSHCONF_INT(client_alive_interval, ClientAliveInterval, SSHCFG_ALL, NULL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  219|      1|SSHCONF_INT(client_alive_count_max, ClientAliveCountMax, SSHCFG_ALL, NULL, 3, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      1|	options->nvar = 0; \
  |  |  |  |  |  |  |  |   93|      1|	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  220|      1|SSHCONF_STRARRAY(authorized_keys_files, num_authkeys_files, AuthorizedKeysFile, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  221|      1|SSHCONF_STRING(adm_forced_command, ForceCommand, SSHCFG_ALL, SSHCFG_COPY_MANUAL) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  222|      1|SSHCONF_INTFLAG(permit_tun, PermitTunnel, SSHCFG_ALL, SSH_TUNMODE_NO, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      1|	options->nvar = 0; \
  |  |  |  |  |  |  |  |   93|      1|	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  223|      1|SSHCONF_STRARRAY(permitted_opens, num_permitted_opens, PermitOpen, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      1|	options->nvar = 0; \
  |  |  |  |  |  |  |  |   93|      1|	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  224|      1|SSHCONF_STRARRAY(permitted_listens, num_permitted_listens, PermitListen, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  225|      1|SSHCONF_STRING(chroot_directory, ChrootDirectory, SSHCFG_ALL, SSHCFG_COPY_MANUAL) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      1|	options->nvar = 0; \
  |  |  |  |  |  |  |  |   93|      1|	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  226|      1|SSHCONF_STRARRAY(revoked_keys_files, num_revoked_keys_files, RevokedKeys, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  227|      1|SSHCONF_STRING(trusted_user_ca_keys, TrustedUserCAKeys, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  228|      1|SSHCONF_STRING(authorized_keys_command, AuthorizedKeysCommand, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  229|      1|SSHCONF_STRING(authorized_keys_command_user, AuthorizedKeysCommandUser, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  230|      1|SSHCONF_STRING(authorized_principals_file, AuthorizedPrincipalsFile, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  231|      1|SSHCONF_STRING(authorized_principals_command, AuthorizedPrincipalsCommand, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  232|      1|SSHCONF_STRING(authorized_principals_command_user, AuthorizedPrincipalsCommandUser, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  233|      1|SSHCONF_STRING(version_addendum, VersionAddendum, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      1|	options->nvar = 0; \
  |  |  |  |  |  |  |  |   93|      1|	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  234|      1|SSHCONF_STRARRAY(auth_methods, num_auth_methods, AuthenticationMethods, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  235|      1|SSHCONF_INT(fingerprint_hash, FingerprintHash, SSHCFG_GLOBAL, NULL, SSH_FP_HASH_DEFAULT, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  236|      1|SSHCONF_INTFLAG(expose_userauth_info, ExposeAuthInfo, SSHCFG_ALL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  237|      1|SSHCONF_STRING(sk_provider, SecurityKeyProvider, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  238|      1|SSHCONF_INT(required_rsa_size, RequiredRSASize, SSHCFG_ALL, NULL, SSH_RSA_MINIMUM_MODULUS_SIZE, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      1|	options->nvar = 0; \
  |  |  |  |  |  |  |  |   93|      1|	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  239|      1|SSHCONF_STRARRAY(channel_timeouts, num_channel_timeouts, ChannelTimeout, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  240|      1|SSHCONF_INT(unused_connection_timeout, UnusedConnectionTimeout, SSHCFG_ALL, NULL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  241|      1|SSHCONF_STRING(sshd_session_path, SshdSessionPath, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  242|      1|SSHCONF_STRING(sshd_auth_path, SshdAuthPath, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  243|      1|SSHCONF_INTFLAG(refuse_connection, RefuseConnection, SSHCFG_ALL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   90|      1|#define SSHCONF_STRING(var, conf, flags, cp)		options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  244|      1|SSHCONF_STRING(agent_socket_path, AgentSocketPath, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   88|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  245|      1|SSHCONF_INT(warn_weak_crypto, WarnWeakCrypto, SSHCFG_GLOBAL, multistate_warnweakcrypto, 1, SSHCFG_COPY_NONE)
  |  |  |  |  ------------------
  |  |  |  |  275|      1|	SSHD_CONFIG_ENTRIES_LEGACY \
  |  |  |  |  276|      1|	SSHD_CONFIG_ENTRIES_ALIASES \
  |  |  |  |  277|      1|	SSHD_CONFIG_ENTRIES_PAM \
  |  |  |  |  ------------------
  |  |  |  |  |  |  285|      1|#define SSHD_CONFIG_ENTRIES_PAM \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   99|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  286|      1|SSHCONF_UNSUPPORTED_INT(use_pam, UsePAM, SSHCFG_GLOBAL) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  100|      1|#define SSHCONF_UNSUPPORTED_STRING(var, conf, flags)	options->var = NULL;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  287|      1|SSHCONF_UNSUPPORTED_STRING(pam_service_name, PAMServiceName, SSHCFG_ALL)
  |  |  |  |  ------------------
  |  |  |  |  278|      1|	SSHD_CONFIG_ENTRIES_LASTLOG
  |  |  |  |  ------------------
  |  |  |  |  |  |  294|      1|#define SSHD_CONFIG_ENTRIES_LASTLOG \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   89|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp)	options->var = -1;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  295|      1|SSHCONF_INTFLAG(print_lastlog, PrintLastLog, SSHCFG_GLOBAL, 1, SSHCFG_COPY_NONE)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  338|      1|	SSHD_CONFIG_ENTRIES_KRB5 \
  |  |  ------------------
  |  |  |  |  315|      1|#define SSHD_CONFIG_ENTRIES_KRB5 \
  |  |  |  |  ------------------
  |  |  |  |  |  |   99|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  316|      1|SSHCONF_UNSUPPORTED_INT(kerberos_authentication, KerberosAuthentication, SSHCFG_ALL) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   99|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  317|      1|SSHCONF_UNSUPPORTED_INT(kerberos_or_local_passwd, KerberosOrLocalPasswd, SSHCFG_GLOBAL) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   99|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  318|      1|SSHCONF_UNSUPPORTED_INT(kerberos_ticket_cleanup, KerberosTicketCleanup, SSHCFG_GLOBAL) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   99|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  319|      1|SSHCONF_UNSUPPORTED_INT(kerberos_get_afs_token, KerberosGetAFSToken, SSHCFG_GLOBAL)
  |  |  ------------------
  |  |  339|      1|	SSHD_CONFIG_ENTRIES_GSS \
  |  |  ------------------
  |  |  |  |  329|      1|#define SSHD_CONFIG_ENTRIES_GSS \
  |  |  |  |  ------------------
  |  |  |  |  |  |   99|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  330|      1|SSHCONF_UNSUPPORTED_INT(gss_authentication, GSSAPIAuthentication, SSHCFG_ALL) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   99|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  331|      1|SSHCONF_UNSUPPORTED_INT(gss_cleanup_creds, GSSAPICleanupCredentials, SSHCFG_GLOBAL) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   99|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  332|      1|SSHCONF_UNSUPPORTED_INT(gss_deleg_creds, GSSAPIDelegateCredentials, SSHCFG_GLOBAL) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   99|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  333|      1|SSHCONF_UNSUPPORTED_INT(gss_strict_acceptor, GSSAPIStrictAcceptorCheck, SSHCFG_GLOBAL)
  |  |  ------------------
  ------------------
  169|       |
  170|      1|#undef init_hostkeyfile
  171|      1|#undef init_ipqos
  172|      1|#undef init_listenaddress
  173|      1|#undef init_logfacility
  174|      1|#undef init_loglevel
  175|      1|#undef init_port
  176|      1|#undef init_gatewayports
  177|      1|#undef init_streamlocalbindmask
  178|      1|#undef init_streamlocalbindunlink
  179|      1|#undef init_maxstartups
  180|      1|#undef init_permituserenv
  181|      1|#undef init_persourcenetblocksize
  182|      1|#undef init_persourcepenalties
  183|      1|#undef init_rekeylimit
  184|      1|#undef init_subsystem
  185|      1|#undef init_timingsecret
  186|      1|#undef SSHCONF_INT
  187|      1|#undef SSHCONF_INTFLAG
  188|      1|#undef SSHCONF_STRING
  189|      1|#undef SSHCONF_STRARRAY
  190|      1|#undef SSHCONF_CUSTOM
  191|      1|#undef SSHCONF_NONCONF
  192|      1|#undef SSHCONF_DEPRECATE
  193|      1|#undef SSHCONF_UNSUPPORTED_INT
  194|      1|#undef SSHCONF_UNSUPPORTED_STRING
  195|      1|#undef SSHCONF_ALIAS
  196|      1|}
servconf_add_hostkey:
  251|      4|{
  252|      4|	char *apath = derelativise_path(path);
  253|       |
  254|      4|	opt_array_append2(file, line, "HostKey",
  255|      4|	    &options->host_key_files, &options->host_key_file_userprovided,
  256|      4|	    &options->num_host_key_files, apath, userprovided);
  257|      4|	free(apath);
  258|      4|}
fill_default_server_options:
  273|      1|{
  274|      1|	u_int i;
  275|       |
  276|       |	/* Portable-specific overrides */
  277|       |#ifdef SKIP_PRIVDROP
  278|       |	if (options->allow_streamlocal_forwarding != -1 &&
  279|       |	    options->allow_streamlocal_forwarding != FORWARD_DENY)
  280|       |		logit("StreamlocalForwarding is not supported on this system");
  281|       |	options->allow_streamlocal_forwarding = 0;
  282|       |	if (options->fwd_opts.gateway_ports != -1 &&
  283|       |	    options->fwd_opts.gateway_ports != 0)
  284|       |		logit("GatewayPorts is not supported on this system");
  285|       |	options->fwd_opts.gateway_ports = 0;
  286|       |#endif
  287|       |
  288|      1|#define SSHCONF_INT(var, conf, flags, ms, def, cp) \
  289|      1|	if (options->var == -1) \
  290|      1|		options->var = def;
  291|      1|#define SSHCONF_INTFLAG(var, conf, flags, def, cp) \
  292|      1|	if (options->var == -1) \
  293|      1|		options->var = def;
  294|      1|#define SSHCONF_STRING(var, conf, flags, cp)		/* done manually */
  295|      1|#define SSHCONF_STRARRAY(var, nvar, conf, flags, cp)	/* done manually */
  296|      1|#define SSHCONF_CUSTOM(conf, funcsuffix, flags, cp)	/* done manually */
  297|      1|#define SSHCONF_NONCONF(funcsuffix)			/* done manually */
  298|      1|#define SSHCONF_DEPRECATE(conf, flags, opcode)		/* empty */
  299|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  300|      1|#define SSHCONF_UNSUPPORTED_STRING(var, conf, flags) \
  301|      1|	do { \
  302|      1|		free(options->var); \
  303|      1|		options->var = NULL; \
  304|      1|	} while (0);
  305|      1|#define SSHCONF_ALIAS(old, conf, flags)			/* empty */
  306|       |
  307|       |	/* XXX maybe use macros here too to force consistency? */
  308|       |
  309|      1|	SSHD_CONFIG_ENTRIES
  ------------------
  |  |  337|      1|	SSHD_CONFIG_ENTRIES_BASE \
  |  |  ------------------
  |  |  |  |  273|      1|	SSHD_CONFIG_ENTRIES_CUSTOM \
  |  |  |  |  274|      1|	SSHD_CONFIG_ENTRIES_MAIN \
  |  |  |  |  ------------------
  |  |  |  |  |  |  167|      1|#define SSHD_CONFIG_ENTRIES_MAIN \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  168|      1|SSHCONF_INT(address_family, AddressFamily, SSHCFG_GLOBAL, multistate_addressfamily, AF_UNSPEC, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  169|      1|SSHCONF_STRING(routing_domain, RDomain, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  170|      1|SSHCONF_STRARRAY(host_cert_files, num_host_cert_files, HostCertificate, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  171|      1|SSHCONF_STRING(host_key_agent, HostKeyAgent, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  172|      1|SSHCONF_STRING(pid_file, PidFile, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  173|      1|SSHCONF_STRING(moduli_file, ModuliFile, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  174|      1|SSHCONF_INT(login_grace_time, LoginGraceTime, SSHCFG_GLOBAL, NULL, SSHD_DEFAULT_LOGIN_GRACE_TIME, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      1|SSHCONF_INT(permit_root_login, PermitRootLogin, SSHCFG_ALL, multistate_permitrootlogin, PERMIT_NO_PASSWD, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  176|      1|SSHCONF_INT(ignore_rhosts, IgnoreRhosts, SSHCFG_ALL, multistate_ignore_rhosts, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  177|      1|SSHCONF_INTFLAG(ignore_user_known_hosts, IgnoreUserKnownHosts, SSHCFG_GLOBAL, 0, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  178|      1|SSHCONF_INTFLAG(print_motd, PrintMotd, SSHCFG_GLOBAL, 1, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  179|      1|SSHCONF_INTFLAG(x11_forwarding, X11Forwarding, SSHCFG_ALL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  180|      1|SSHCONF_INT(x11_display_offset, X11DisplayOffset, SSHCFG_ALL, NULL, SSHD_DEFAULT_X11_DISPLAY_OFFSET, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|SSHCONF_INTFLAG(x11_use_localhost, X11UseLocalhost, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  182|      1|SSHCONF_STRING(xauth_location, XAuthLocation, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  183|      1|SSHCONF_INTFLAG(permit_tty, PermitTTY, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      1|SSHCONF_INTFLAG(permit_user_rc, PermitUserRC, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  185|      1|SSHCONF_INTFLAG(strict_modes, StrictModes, SSHCFG_GLOBAL, 1, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  186|      1|SSHCONF_INTFLAG(tcp_keep_alive, TCPKeepAlive, SSHCFG_GLOBAL, SSH_KEEPALIVES_TRANSPORT, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  187|      1|SSHCONF_STRING(ciphers, Ciphers, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  188|      1|SSHCONF_STRING(macs, Macs, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  189|      1|SSHCONF_STRING(kex_algorithms, KexAlgorithms, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  190|      1|SSHCONF_STRARRAY(log_verbose, num_log_verbose, LogVerbose, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  191|      1|SSHCONF_INTFLAG(hostbased_authentication, HostbasedAuthentication, SSHCFG_ALL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  192|      1|SSHCONF_INTFLAG(hostbased_uses_name_from_packet_only, HostbasedUsesNameFromPacketOnly, SSHCFG_ALL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  193|      1|SSHCONF_STRING(hostbased_accepted_algos, HostbasedAcceptedAlgorithms, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  194|      1|SSHCONF_STRING(hostkeyalgorithms, HostKeyAlgorithms, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  195|      1|SSHCONF_STRING(ca_sign_algorithms, CASignatureAlgorithms, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  196|      1|SSHCONF_INTFLAG(pubkey_authentication, PubkeyAuthentication, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  197|      1|SSHCONF_STRING(pubkey_accepted_algos, PubkeyAcceptedAlgorithms, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  198|      1|SSHCONF_INTFLAG(password_authentication, PasswordAuthentication, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  199|      1|SSHCONF_INTFLAG(kbd_interactive_authentication, KbdInteractiveAuthentication, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  200|      1|SSHCONF_INTFLAG(permit_empty_passwd, PermitEmptyPasswords, SSHCFG_ALL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  201|      1|SSHCONF_INT(compression, Compression, SSHCFG_GLOBAL, multistate_compression, SSHD_DEFAULT_COMPRESSION, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  202|      1|SSHCONF_INT(allow_tcp_forwarding, AllowTcpForwarding, SSHCFG_ALL, multistate_tcpfwd, FORWARD_ALLOW, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  203|      1|SSHCONF_INT(allow_streamlocal_forwarding, AllowStreamLocalForwarding, SSHCFG_ALL, multistate_tcpfwd, FORWARD_ALLOW, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  204|      1|SSHCONF_INTFLAG(allow_agent_forwarding, AllowAgentForwarding, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  205|      1|SSHCONF_INTFLAG(disable_forwarding, DisableForwarding, SSHCFG_ALL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  206|      1|SSHCONF_STRARRAY(allow_users, num_allow_users, AllowUsers, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  207|      1|SSHCONF_STRARRAY(deny_users, num_deny_users, DenyUsers, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  208|      1|SSHCONF_STRARRAY(allow_groups, num_allow_groups, AllowGroups, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  209|      1|SSHCONF_STRARRAY(deny_groups, num_deny_groups, DenyGroups, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  210|      1|SSHCONF_STRARRAY(accept_env, num_accept_env, AcceptEnv, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  211|      1|SSHCONF_STRARRAY(setenv, num_setenv, SetEnv, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  212|      1|SSHCONF_INT(per_source_max_startups, PerSourceMaxStartups, SSHCFG_GLOBAL, NULL, INT_MAX, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  213|      1|SSHCONF_STRING(per_source_penalty_exempt, PerSourcePenaltyExemptList, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  214|      1|SSHCONF_INT(max_authtries, MaxAuthTries, SSHCFG_ALL, NULL, DEFAULT_AUTH_FAIL_MAX, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  215|      1|SSHCONF_INT(max_sessions, MaxSessions, SSHCFG_ALL, NULL, DEFAULT_SESSIONS_MAX, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  216|      1|SSHCONF_STRING(banner, Banner, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      1|SSHCONF_INTFLAG(use_dns, UseDNS, SSHCFG_GLOBAL, 0, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  218|      1|SSHCONF_INT(client_alive_interval, ClientAliveInterval, SSHCFG_ALL, NULL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  219|      1|SSHCONF_INT(client_alive_count_max, ClientAliveCountMax, SSHCFG_ALL, NULL, 3, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  220|      1|SSHCONF_STRARRAY(authorized_keys_files, num_authkeys_files, AuthorizedKeysFile, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  221|      1|SSHCONF_STRING(adm_forced_command, ForceCommand, SSHCFG_ALL, SSHCFG_COPY_MANUAL) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  222|      1|SSHCONF_INTFLAG(permit_tun, PermitTunnel, SSHCFG_ALL, SSH_TUNMODE_NO, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  223|      1|SSHCONF_STRARRAY(permitted_opens, num_permitted_opens, PermitOpen, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  224|      1|SSHCONF_STRARRAY(permitted_listens, num_permitted_listens, PermitListen, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  225|      1|SSHCONF_STRING(chroot_directory, ChrootDirectory, SSHCFG_ALL, SSHCFG_COPY_MANUAL) \
  |  |  |  |  |  |  226|      1|SSHCONF_STRARRAY(revoked_keys_files, num_revoked_keys_files, RevokedKeys, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  227|      1|SSHCONF_STRING(trusted_user_ca_keys, TrustedUserCAKeys, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  228|      1|SSHCONF_STRING(authorized_keys_command, AuthorizedKeysCommand, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  229|      1|SSHCONF_STRING(authorized_keys_command_user, AuthorizedKeysCommandUser, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  230|      1|SSHCONF_STRING(authorized_principals_file, AuthorizedPrincipalsFile, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  231|      1|SSHCONF_STRING(authorized_principals_command, AuthorizedPrincipalsCommand, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  232|      1|SSHCONF_STRING(authorized_principals_command_user, AuthorizedPrincipalsCommandUser, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  233|      1|SSHCONF_STRING(version_addendum, VersionAddendum, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  234|      1|SSHCONF_STRARRAY(auth_methods, num_auth_methods, AuthenticationMethods, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  235|      1|SSHCONF_INT(fingerprint_hash, FingerprintHash, SSHCFG_GLOBAL, NULL, SSH_FP_HASH_DEFAULT, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  236|      1|SSHCONF_INTFLAG(expose_userauth_info, ExposeAuthInfo, SSHCFG_ALL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  237|      1|SSHCONF_STRING(sk_provider, SecurityKeyProvider, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  238|      1|SSHCONF_INT(required_rsa_size, RequiredRSASize, SSHCFG_ALL, NULL, SSH_RSA_MINIMUM_MODULUS_SIZE, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  239|      1|SSHCONF_STRARRAY(channel_timeouts, num_channel_timeouts, ChannelTimeout, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  240|      1|SSHCONF_INT(unused_connection_timeout, UnusedConnectionTimeout, SSHCFG_ALL, NULL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  241|      1|SSHCONF_STRING(sshd_session_path, SshdSessionPath, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  242|      1|SSHCONF_STRING(sshd_auth_path, SshdAuthPath, SSHCFG_GLOBAL, SSHCFG_COPY_NONE) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  243|      1|SSHCONF_INTFLAG(refuse_connection, RefuseConnection, SSHCFG_ALL, 0, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  244|      1|SSHCONF_STRING(agent_socket_path, AgentSocketPath, SSHCFG_ALL, SSHCFG_COPY_MATCH) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  289|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (289:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  245|      1|SSHCONF_INT(warn_weak_crypto, WarnWeakCrypto, SSHCFG_GLOBAL, multistate_warnweakcrypto, 1, SSHCFG_COPY_NONE)
  |  |  |  |  ------------------
  |  |  |  |  275|      1|	SSHD_CONFIG_ENTRIES_LEGACY \
  |  |  |  |  276|      1|	SSHD_CONFIG_ENTRIES_ALIASES \
  |  |  |  |  277|      1|	SSHD_CONFIG_ENTRIES_PAM \
  |  |  |  |  ------------------
  |  |  |  |  |  |  285|      1|#define SSHD_CONFIG_ENTRIES_PAM \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  299|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  286|      1|SSHCONF_UNSUPPORTED_INT(use_pam, UsePAM, SSHCFG_GLOBAL) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  301|      1|	do { \
  |  |  |  |  |  |  |  |  302|      1|		free(options->var); \
  |  |  |  |  |  |  |  |  303|      1|		options->var = NULL; \
  |  |  |  |  |  |  |  |  304|      1|	} while (0);
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (304:11): [Folded, False: 1]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  287|      1|SSHCONF_UNSUPPORTED_STRING(pam_service_name, PAMServiceName, SSHCFG_ALL)
  |  |  |  |  ------------------
  |  |  |  |  278|      1|	SSHD_CONFIG_ENTRIES_LASTLOG
  |  |  |  |  ------------------
  |  |  |  |  |  |  294|      1|#define SSHD_CONFIG_ENTRIES_LASTLOG \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      1|	if (options->var == -1) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (292:6): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  293|      1|		options->var = def;
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  295|      1|SSHCONF_INTFLAG(print_lastlog, PrintLastLog, SSHCFG_GLOBAL, 1, SSHCFG_COPY_NONE)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  338|      1|	SSHD_CONFIG_ENTRIES_KRB5 \
  |  |  ------------------
  |  |  |  |  315|      1|#define SSHD_CONFIG_ENTRIES_KRB5 \
  |  |  |  |  ------------------
  |  |  |  |  |  |  299|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  316|      1|SSHCONF_UNSUPPORTED_INT(kerberos_authentication, KerberosAuthentication, SSHCFG_ALL) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  299|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  317|      1|SSHCONF_UNSUPPORTED_INT(kerberos_or_local_passwd, KerberosOrLocalPasswd, SSHCFG_GLOBAL) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  299|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  318|      1|SSHCONF_UNSUPPORTED_INT(kerberos_ticket_cleanup, KerberosTicketCleanup, SSHCFG_GLOBAL) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  299|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  319|      1|SSHCONF_UNSUPPORTED_INT(kerberos_get_afs_token, KerberosGetAFSToken, SSHCFG_GLOBAL)
  |  |  ------------------
  |  |  339|      1|	SSHD_CONFIG_ENTRIES_GSS \
  |  |  ------------------
  |  |  |  |  329|      1|#define SSHD_CONFIG_ENTRIES_GSS \
  |  |  |  |  ------------------
  |  |  |  |  |  |  299|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  330|      1|SSHCONF_UNSUPPORTED_INT(gss_authentication, GSSAPIAuthentication, SSHCFG_ALL) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  299|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  331|      1|SSHCONF_UNSUPPORTED_INT(gss_cleanup_creds, GSSAPICleanupCredentials, SSHCFG_GLOBAL) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  299|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  332|      1|SSHCONF_UNSUPPORTED_INT(gss_deleg_creds, GSSAPIDelegateCredentials, SSHCFG_GLOBAL) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  299|      1|#define SSHCONF_UNSUPPORTED_INT(var, conf, flags)	options->var = 0;
  |  |  |  |  ------------------
  |  |  |  |  333|      1|SSHCONF_UNSUPPORTED_INT(gss_strict_acceptor, GSSAPIStrictAcceptorCheck, SSHCFG_GLOBAL)
  |  |  ------------------
  ------------------
  310|       |
  311|      1|#undef SSHCONF_INT
  312|      1|#undef SSHCONF_INTFLAG
  313|      1|#undef SSHCONF_STRING
  314|      1|#undef SSHCONF_STRARRAY
  315|      1|#undef SSHCONF_CUSTOM
  316|      1|#undef SSHCONF_NONCONF
  317|      1|#undef SSHCONF_DEPRECATE
  318|      1|#undef SSHCONF_UNSUPPORTED_INT
  319|      1|#undef SSHCONF_UNSUPPORTED_STRING
  320|      1|#undef SSHCONF_ALIAS
  321|       |
  322|       |#ifdef USE_PAM
  323|       |	if (options->pam_service_name == NULL)
  324|       |		options->pam_service_name = xstrdup(SSHD_PAM_SERVICE);
  325|       |#endif
  326|       |
  327|      1|	if (options->num_host_key_files == 0) {
  ------------------
  |  Branch (327:6): [True: 1, False: 0]
  ------------------
  328|       |		/* fill default hostkeys */
  329|      1|		servconf_add_hostkey("[default]", 0, options,
  330|      1|		    _PATH_HOST_RSA_KEY_FILE, 0);
  ------------------
  |  |   40|      1|#define _PATH_HOST_RSA_KEY_FILE		SSHDIR "/ssh_host_rsa_key"
  ------------------
  331|      1|		servconf_add_hostkey("[default]", 0, options,
  332|      1|		    _PATH_HOST_ECDSA_KEY_FILE, 0);
  ------------------
  |  |   39|      1|#define _PATH_HOST_ECDSA_KEY_FILE	SSHDIR "/ssh_host_ecdsa_key"
  ------------------
  333|      1|		servconf_add_hostkey("[default]", 0, options,
  334|      1|		    _PATH_HOST_ED25519_KEY_FILE, 0);
  ------------------
  |  |   41|      1|#define _PATH_HOST_ED25519_KEY_FILE	SSHDIR "/ssh_host_ed25519_key"
  ------------------
  335|      1|		servconf_add_hostkey("[default]", 0, options,
  336|      1|		    _PATH_HOST_MLDSA44_ED25519_KEY_FILE, 0);
  ------------------
  |  |   42|      1|#define _PATH_HOST_MLDSA44_ED25519_KEY_FILE SSHDIR "/ssh_host_mldsa44_ed25519_key"
  ------------------
  337|      1|	}
  338|       |	/* No certificates by default */
  339|      1|	if (options->num_ports == 0)
  ------------------
  |  Branch (339:6): [True: 1, False: 0]
  ------------------
  340|      1|		options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
  ------------------
  |  |   16|      1|#define SSH_DEFAULT_PORT	22
  ------------------
  341|      1|	if (options->listen_addrs == NULL)
  ------------------
  |  Branch (341:6): [True: 1, False: 0]
  ------------------
  342|      1|		add_listen_addr(options, NULL, NULL, 0);
  343|      1|	if (options->pid_file == NULL)
  ------------------
  |  Branch (343:6): [True: 1, False: 0]
  ------------------
  344|      1|		options->pid_file = xstrdup(_PATH_SSH_DAEMON_PID_FILE);
  ------------------
  |  |   61|      1|#define _PATH_SSH_DAEMON_PID_FILE	_PATH_SSH_PIDDIR "/sshd.pid"
  |  |  ------------------
  |  |  |  | 2094|      1|#define _PATH_SSH_PIDDIR "/var/run"
  |  |  ------------------
  ------------------
  345|      1|	if (options->moduli_file == NULL)
  ------------------
  |  Branch (345:6): [True: 1, False: 0]
  ------------------
  346|      1|		options->moduli_file = xstrdup(_PATH_DH_MODULI);
  ------------------
  |  |   43|      1|#define _PATH_DH_MODULI			SSHDIR "/moduli"
  ------------------
  347|      1|	if (options->xauth_location == NULL)
  ------------------
  |  Branch (347:6): [True: 1, False: 0]
  ------------------
  348|      1|		options->xauth_location = xstrdup(_PATH_XAUTH);
  ------------------
  |  |  476|      1|#define _PATH_XAUTH XAUTH_PATH
  |  |  ------------------
  |  |  |  | 2074|      1|#define XAUTH_PATH "/usr/bin/xauth"
  |  |  ------------------
  ------------------
  349|      1|	if (options->log_facility == SYSLOG_FACILITY_NOT_SET)
  ------------------
  |  Branch (349:6): [True: 1, False: 0]
  ------------------
  350|      1|		options->log_facility = SYSLOG_FACILITY_AUTH;
  351|      1|	if (options->log_level == SYSLOG_LEVEL_NOT_SET)
  ------------------
  |  Branch (351:6): [True: 1, False: 0]
  ------------------
  352|      1|		options->log_level = SYSLOG_LEVEL_INFO;
  353|      1|	if (options->permit_user_env == -1) {
  ------------------
  |  Branch (353:6): [True: 1, False: 0]
  ------------------
  354|      1|		options->permit_user_env = 0;
  355|      1|		options->permit_user_env_allowlist = NULL;
  356|      1|	}
  357|      1|	if (options->rekey_limit == -1)
  ------------------
  |  Branch (357:6): [True: 1, False: 0]
  ------------------
  358|      1|		options->rekey_limit = 0;
  359|      1|	if (options->rekey_interval == -1)
  ------------------
  |  Branch (359:6): [True: 1, False: 0]
  ------------------
  360|      1|		options->rekey_interval = 0;
  361|      1|	if (options->fwd_opts.gateway_ports == -1)
  ------------------
  |  Branch (361:6): [True: 1, False: 0]
  ------------------
  362|      1|		options->fwd_opts.gateway_ports = 0;
  363|      1|	if (options->max_startups == -1)
  ------------------
  |  Branch (363:6): [True: 1, False: 0]
  ------------------
  364|      1|		options->max_startups = 100;
  365|      1|	if (options->max_startups_rate == -1)
  ------------------
  |  Branch (365:6): [True: 1, False: 0]
  ------------------
  366|      1|		options->max_startups_rate = 30;		/* 30% */
  367|      1|	if (options->max_startups_begin == -1)
  ------------------
  |  Branch (367:6): [True: 1, False: 0]
  ------------------
  368|      1|		options->max_startups_begin = 10;
  369|      1|	if (options->per_source_masklen_ipv4 == -1)
  ------------------
  |  Branch (369:6): [True: 1, False: 0]
  ------------------
  370|      1|		options->per_source_masklen_ipv4 = 32;
  371|      1|	if (options->per_source_masklen_ipv6 == -1)
  ------------------
  |  Branch (371:6): [True: 1, False: 0]
  ------------------
  372|      1|		options->per_source_masklen_ipv6 = 128;
  373|      1|	if (options->per_source_penalty.enabled == -1)
  ------------------
  |  Branch (373:6): [True: 1, False: 0]
  ------------------
  374|      1|		options->per_source_penalty.enabled = 1;
  375|      1|	if (options->per_source_penalty.max_sources4 == -1)
  ------------------
  |  Branch (375:6): [True: 1, False: 0]
  ------------------
  376|      1|		options->per_source_penalty.max_sources4 = 65536;
  377|      1|	if (options->per_source_penalty.max_sources6 == -1)
  ------------------
  |  Branch (377:6): [True: 1, False: 0]
  ------------------
  378|      1|		options->per_source_penalty.max_sources6 = 65536;
  379|      1|	if (options->per_source_penalty.overflow_mode == -1)
  ------------------
  |  Branch (379:6): [True: 1, False: 0]
  ------------------
  380|      1|		options->per_source_penalty.overflow_mode = PER_SOURCE_PENALTY_OVERFLOW_PERMISSIVE;
  ------------------
  |  |   85|      1|#define PER_SOURCE_PENALTY_OVERFLOW_PERMISSIVE	2
  ------------------
  381|      1|	if (options->per_source_penalty.overflow_mode6 == -1)
  ------------------
  |  Branch (381:6): [True: 1, False: 0]
  ------------------
  382|      1|		options->per_source_penalty.overflow_mode6 = options->per_source_penalty.overflow_mode;
  383|      1|	if (options->per_source_penalty.penalty_crash < 0.0)
  ------------------
  |  Branch (383:6): [True: 1, False: 0]
  ------------------
  384|      1|		options->per_source_penalty.penalty_crash = 90.0;
  385|      1|	if (options->per_source_penalty.penalty_grace < 0.0)
  ------------------
  |  Branch (385:6): [True: 1, False: 0]
  ------------------
  386|      1|		options->per_source_penalty.penalty_grace = 10.0;
  387|      1|	if (options->per_source_penalty.penalty_authfail < 0.0)
  ------------------
  |  Branch (387:6): [True: 1, False: 0]
  ------------------
  388|      1|		options->per_source_penalty.penalty_authfail = 5.0;
  389|      1|	if (options->per_source_penalty.penalty_invaliduser < 0.0)
  ------------------
  |  Branch (389:6): [True: 1, False: 0]
  ------------------
  390|      1|		options->per_source_penalty.penalty_invaliduser = 5.0;
  391|      1|	if (options->per_source_penalty.penalty_noauth < 0.0)
  ------------------
  |  Branch (391:6): [True: 1, False: 0]
  ------------------
  392|      1|		options->per_source_penalty.penalty_noauth = 1.0;
  393|      1|	if (options->per_source_penalty.penalty_refuseconnection < 0.0)
  ------------------
  |  Branch (393:6): [True: 1, False: 0]
  ------------------
  394|      1|		options->per_source_penalty.penalty_refuseconnection = 10.0;
  395|      1|	if (options->per_source_penalty.penalty_min < 0.0)
  ------------------
  |  Branch (395:6): [True: 1, False: 0]
  ------------------
  396|      1|		options->per_source_penalty.penalty_min = 15.0;
  397|      1|	if (options->per_source_penalty.penalty_max < 0.0)
  ------------------
  |  Branch (397:6): [True: 1, False: 0]
  ------------------
  398|      1|		options->per_source_penalty.penalty_max = 600.0;
  399|      1|	if (options->num_authkeys_files == 0) {
  ------------------
  |  Branch (399:6): [True: 1, False: 0]
  ------------------
  400|      1|		opt_array_append("[default]", 0, "AuthorizedKeysFiles",
  401|      1|		    &options->authorized_keys_files,
  402|      1|		    &options->num_authkeys_files,
  403|      1|		    _PATH_SSH_USER_PERMITTED_KEYS);
  ------------------
  |  |  115|      1|#define _PATH_SSH_USER_PERMITTED_KEYS	_PATH_SSH_USER_DIR "/authorized_keys"
  |  |  ------------------
  |  |  |  |   67|      1|#define _PATH_SSH_USER_DIR		".ssh"
  |  |  ------------------
  ------------------
  404|      1|		opt_array_append("[default]", 0, "AuthorizedKeysFiles",
  405|      1|		    &options->authorized_keys_files,
  406|      1|		    &options->num_authkeys_files,
  407|      1|		    _PATH_SSH_USER_PERMITTED_KEYS2);
  ------------------
  |  |  118|      1|#define _PATH_SSH_USER_PERMITTED_KEYS2	_PATH_SSH_USER_DIR "/authorized_keys2"
  |  |  ------------------
  |  |  |  |   67|      1|#define _PATH_SSH_USER_DIR		".ssh"
  |  |  ------------------
  ------------------
  408|      1|	}
  409|      1|	if (options->ip_qos_interactive == -1)
  ------------------
  |  Branch (409:6): [True: 1, False: 0]
  ------------------
  410|      1|		options->ip_qos_interactive = IPTOS_DSCP_EF;
  411|      1|	if (options->ip_qos_bulk == -1)
  ------------------
  |  Branch (411:6): [True: 1, False: 0]
  ------------------
  412|      1|		options->ip_qos_bulk = IPTOS_DSCP_CS0;
  ------------------
  |  |   88|      1|# define	IPTOS_DSCP_CS0		0x00
  ------------------
  413|      1|	if (options->version_addendum == NULL)
  ------------------
  |  Branch (413:6): [True: 1, False: 0]
  ------------------
  414|      1|		options->version_addendum = xstrdup("");
  415|      1|	if (options->fwd_opts.streamlocal_bind_mask == (mode_t)-1)
  ------------------
  |  Branch (415:6): [True: 1, False: 0]
  ------------------
  416|      1|		options->fwd_opts.streamlocal_bind_mask = 0177;
  417|      1|	if (options->fwd_opts.streamlocal_bind_unlink == -1)
  ------------------
  |  Branch (417:6): [True: 1, False: 0]
  ------------------
  418|      1|		options->fwd_opts.streamlocal_bind_unlink = 0;
  419|      1|	if (options->sk_provider == NULL)
  ------------------
  |  Branch (419:6): [True: 1, False: 0]
  ------------------
  420|      1|		options->sk_provider = xstrdup("internal");
  421|      1|	if (options->sshd_session_path == NULL)
  ------------------
  |  Branch (421:6): [True: 1, False: 0]
  ------------------
  422|      1|		options->sshd_session_path = xstrdup(_PATH_SSHD_SESSION);
  423|      1|	if (options->sshd_auth_path == NULL)
  ------------------
  |  Branch (423:6): [True: 1, False: 0]
  ------------------
  424|      1|		options->sshd_auth_path = xstrdup(_PATH_SSHD_AUTH);
  425|      1|	if (options->pubkey_auth_options == -1) {
  ------------------
  |  Branch (425:6): [True: 1, False: 0]
  ------------------
  426|      1|		options->pubkey_auth_options = 0;
  427|      1|		options->max_pubkey_ok = DEFAULT_AUTH_FAIL_MAX;
  ------------------
  |  |   41|      1|#define DEFAULT_AUTH_FAIL_MAX	6	/* Default for MaxAuthTries */
  ------------------
  428|      1|	}
  429|      1|	if (options->agent_socket_path == NULL)
  ------------------
  |  Branch (429:6): [True: 1, False: 0]
  ------------------
  430|      1|		options->agent_socket_path = xstrdup(_PATH_SSH_AGENT_SOCKET_DIR);
  ------------------
  |  |   74|      1|#define _PATH_SSH_AGENT_SOCKET_DIR	"user:" _PATH_SSH_USER_DIR "/agent"
  ------------------
  431|       |
  432|      1|	assemble_algorithms(options);
  433|       |
  434|      1|#define CLEAR_ON_NONE(v) \
  435|      1|	do { \
  436|      1|		if (option_clear_or_none(v)) { \
  437|      1|			free(v); \
  438|      1|			v = NULL; \
  439|      1|		} \
  440|      1|	} while(0)
  441|      1|#define CLEAR_ON_NONE_ARRAY(v, nv, none) \
  442|      1|	do { \
  443|      1|		if (options->nv == 1 && \
  444|      1|		    strcasecmp(options->v[0], none) == 0) { \
  445|      1|			free(options->v[0]); \
  446|      1|			free(options->v); \
  447|      1|			options->v = NULL; \
  448|      1|			options->nv = 0; \
  449|      1|		} \
  450|      1|	} while (0)
  451|      1|	CLEAR_ON_NONE(options->pid_file);
  ------------------
  |  |  435|      1|	do { \
  |  |  436|      1|		if (option_clear_or_none(v)) { \
  |  |  ------------------
  |  |  |  Branch (436:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  437|      0|			free(v); \
  |  |  438|      0|			v = NULL; \
  |  |  439|      0|		} \
  |  |  440|      1|	} while(0)
  |  |  ------------------
  |  |  |  Branch (440:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  452|      1|	CLEAR_ON_NONE(options->xauth_location);
  ------------------
  |  |  435|      1|	do { \
  |  |  436|      1|		if (option_clear_or_none(v)) { \
  |  |  ------------------
  |  |  |  Branch (436:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  437|      0|			free(v); \
  |  |  438|      0|			v = NULL; \
  |  |  439|      0|		} \
  |  |  440|      1|	} while(0)
  |  |  ------------------
  |  |  |  Branch (440:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  453|      1|	CLEAR_ON_NONE(options->banner);
  ------------------
  |  |  435|      1|	do { \
  |  |  436|      1|		if (option_clear_or_none(v)) { \
  |  |  ------------------
  |  |  |  Branch (436:7): [True: 1, False: 0]
  |  |  ------------------
  |  |  437|      1|			free(v); \
  |  |  438|      1|			v = NULL; \
  |  |  439|      1|		} \
  |  |  440|      1|	} while(0)
  |  |  ------------------
  |  |  |  Branch (440:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  454|      1|	CLEAR_ON_NONE(options->trusted_user_ca_keys);
  ------------------
  |  |  435|      1|	do { \
  |  |  436|      1|		if (option_clear_or_none(v)) { \
  |  |  ------------------
  |  |  |  Branch (436:7): [True: 1, False: 0]
  |  |  ------------------
  |  |  437|      1|			free(v); \
  |  |  438|      1|			v = NULL; \
  |  |  439|      1|		} \
  |  |  440|      1|	} while(0)
  |  |  ------------------
  |  |  |  Branch (440:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  455|      1|	CLEAR_ON_NONE(options->sk_provider);
  ------------------
  |  |  435|      1|	do { \
  |  |  436|      1|		if (option_clear_or_none(v)) { \
  |  |  ------------------
  |  |  |  Branch (436:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  437|      0|			free(v); \
  |  |  438|      0|			v = NULL; \
  |  |  439|      0|		} \
  |  |  440|      1|	} while(0)
  |  |  ------------------
  |  |  |  Branch (440:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  456|      1|	CLEAR_ON_NONE(options->authorized_principals_file);
  ------------------
  |  |  435|      1|	do { \
  |  |  436|      1|		if (option_clear_or_none(v)) { \
  |  |  ------------------
  |  |  |  Branch (436:7): [True: 1, False: 0]
  |  |  ------------------
  |  |  437|      1|			free(v); \
  |  |  438|      1|			v = NULL; \
  |  |  439|      1|		} \
  |  |  440|      1|	} while(0)
  |  |  ------------------
  |  |  |  Branch (440:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  457|      1|	CLEAR_ON_NONE(options->adm_forced_command);
  ------------------
  |  |  435|      1|	do { \
  |  |  436|      1|		if (option_clear_or_none(v)) { \
  |  |  ------------------
  |  |  |  Branch (436:7): [True: 1, False: 0]
  |  |  ------------------
  |  |  437|      1|			free(v); \
  |  |  438|      1|			v = NULL; \
  |  |  439|      1|		} \
  |  |  440|      1|	} while(0)
  |  |  ------------------
  |  |  |  Branch (440:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  458|      1|	CLEAR_ON_NONE(options->chroot_directory);
  ------------------
  |  |  435|      1|	do { \
  |  |  436|      1|		if (option_clear_or_none(v)) { \
  |  |  ------------------
  |  |  |  Branch (436:7): [True: 1, False: 0]
  |  |  ------------------
  |  |  437|      1|			free(v); \
  |  |  438|      1|			v = NULL; \
  |  |  439|      1|		} \
  |  |  440|      1|	} while(0)
  |  |  ------------------
  |  |  |  Branch (440:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  459|      1|	CLEAR_ON_NONE(options->routing_domain);
  ------------------
  |  |  435|      1|	do { \
  |  |  436|      1|		if (option_clear_or_none(v)) { \
  |  |  ------------------
  |  |  |  Branch (436:7): [True: 1, False: 0]
  |  |  ------------------
  |  |  437|      1|			free(v); \
  |  |  438|      1|			v = NULL; \
  |  |  439|      1|		} \
  |  |  440|      1|	} while(0)
  |  |  ------------------
  |  |  |  Branch (440:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  460|      1|	CLEAR_ON_NONE(options->host_key_agent);
  ------------------
  |  |  435|      1|	do { \
  |  |  436|      1|		if (option_clear_or_none(v)) { \
  |  |  ------------------
  |  |  |  Branch (436:7): [True: 1, False: 0]
  |  |  ------------------
  |  |  437|      1|			free(v); \
  |  |  438|      1|			v = NULL; \
  |  |  439|      1|		} \
  |  |  440|      1|	} while(0)
  |  |  ------------------
  |  |  |  Branch (440:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  461|      1|	CLEAR_ON_NONE(options->per_source_penalty_exempt);
  ------------------
  |  |  435|      1|	do { \
  |  |  436|      1|		if (option_clear_or_none(v)) { \
  |  |  ------------------
  |  |  |  Branch (436:7): [True: 1, False: 0]
  |  |  ------------------
  |  |  437|      1|			free(v); \
  |  |  438|      1|			v = NULL; \
  |  |  439|      1|		} \
  |  |  440|      1|	} while(0)
  |  |  ------------------
  |  |  |  Branch (440:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  462|      1|	CLEAR_ON_NONE(options->agent_socket_path);
  ------------------
  |  |  435|      1|	do { \
  |  |  436|      1|		if (option_clear_or_none(v)) { \
  |  |  ------------------
  |  |  |  Branch (436:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  437|      0|			free(v); \
  |  |  438|      0|			v = NULL; \
  |  |  439|      0|		} \
  |  |  440|      1|	} while(0)
  |  |  ------------------
  |  |  |  Branch (440:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  463|       |
  464|      5|	for (i = 0; i < options->num_host_key_files; i++)
  ------------------
  |  Branch (464:14): [True: 4, False: 1]
  ------------------
  465|      4|		CLEAR_ON_NONE(options->host_key_files[i]);
  ------------------
  |  |  435|      4|	do { \
  |  |  436|      4|		if (option_clear_or_none(v)) { \
  |  |  ------------------
  |  |  |  Branch (436:7): [True: 0, False: 4]
  |  |  ------------------
  |  |  437|      0|			free(v); \
  |  |  438|      0|			v = NULL; \
  |  |  439|      0|		} \
  |  |  440|      4|	} while(0)
  |  |  ------------------
  |  |  |  Branch (440:10): [Folded, False: 4]
  |  |  ------------------
  ------------------
  466|      1|	for (i = 0; i < options->num_host_cert_files; i++)
  ------------------
  |  Branch (466:14): [True: 0, False: 1]
  ------------------
  467|      0|		CLEAR_ON_NONE(options->host_cert_files[i]);
  ------------------
  |  |  435|      0|	do { \
  |  |  436|      0|		if (option_clear_or_none(v)) { \
  |  |  ------------------
  |  |  |  Branch (436:7): [True: 0, False: 0]
  |  |  ------------------
  |  |  437|      0|			free(v); \
  |  |  438|      0|			v = NULL; \
  |  |  439|      0|		} \
  |  |  440|      0|	} while(0)
  |  |  ------------------
  |  |  |  Branch (440:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  468|       |
  469|      1|	CLEAR_ON_NONE_ARRAY(channel_timeouts, num_channel_timeouts, "none");
  ------------------
  |  |  442|      1|	do { \
  |  |  443|      1|		if (options->nv == 1 && \
  |  |  ------------------
  |  |  |  Branch (443:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  444|      1|		    strcasecmp(options->v[0], none) == 0) { \
  |  |  ------------------
  |  |  |  Branch (444:7): [True: 0, False: 0]
  |  |  ------------------
  |  |  445|      0|			free(options->v[0]); \
  |  |  446|      0|			free(options->v); \
  |  |  447|      0|			options->v = NULL; \
  |  |  448|      0|			options->nv = 0; \
  |  |  449|      0|		} \
  |  |  450|      1|	} while (0)
  |  |  ------------------
  |  |  |  Branch (450:11): [Folded, False: 1]
  |  |  ------------------
  ------------------
  470|      1|	CLEAR_ON_NONE_ARRAY(auth_methods, num_auth_methods, "any");
  ------------------
  |  |  442|      1|	do { \
  |  |  443|      1|		if (options->nv == 1 && \
  |  |  ------------------
  |  |  |  Branch (443:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  444|      1|		    strcasecmp(options->v[0], none) == 0) { \
  |  |  ------------------
  |  |  |  Branch (444:7): [True: 0, False: 0]
  |  |  ------------------
  |  |  445|      0|			free(options->v[0]); \
  |  |  446|      0|			free(options->v); \
  |  |  447|      0|			options->v = NULL; \
  |  |  448|      0|			options->nv = 0; \
  |  |  449|      0|		} \
  |  |  450|      1|	} while (0)
  |  |  ------------------
  |  |  |  Branch (450:11): [Folded, False: 1]
  |  |  ------------------
  ------------------
  471|      1|	CLEAR_ON_NONE_ARRAY(revoked_keys_files, num_revoked_keys_files, "none");
  ------------------
  |  |  442|      1|	do { \
  |  |  443|      1|		if (options->nv == 1 && \
  |  |  ------------------
  |  |  |  Branch (443:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  444|      1|		    strcasecmp(options->v[0], none) == 0) { \
  |  |  ------------------
  |  |  |  Branch (444:7): [True: 0, False: 0]
  |  |  ------------------
  |  |  445|      0|			free(options->v[0]); \
  |  |  446|      0|			free(options->v); \
  |  |  447|      0|			options->v = NULL; \
  |  |  448|      0|			options->nv = 0; \
  |  |  449|      0|		} \
  |  |  450|      1|	} while (0)
  |  |  ------------------
  |  |  |  Branch (450:11): [Folded, False: 1]
  |  |  ------------------
  ------------------
  472|       |	CLEAR_ON_NONE_ARRAY(authorized_keys_files, num_authkeys_files, "none");
  ------------------
  |  |  442|      1|	do { \
  |  |  443|      1|		if (options->nv == 1 && \
  |  |  ------------------
  |  |  |  Branch (443:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  444|      1|		    strcasecmp(options->v[0], none) == 0) { \
  |  |  ------------------
  |  |  |  Branch (444:7): [True: 0, False: 0]
  |  |  ------------------
  |  |  445|      0|			free(options->v[0]); \
  |  |  446|      0|			free(options->v); \
  |  |  447|      0|			options->v = NULL; \
  |  |  448|      0|			options->nv = 0; \
  |  |  449|      0|		} \
  |  |  450|      1|	} while (0)
  |  |  ------------------
  |  |  |  Branch (450:11): [Folded, False: 1]
  |  |  ------------------
  ------------------
  473|      1|#undef CLEAR_ON_NONE
  474|      1|#undef CLEAR_ON_NONE_ARRAY
  475|      1|}
derelativise_path:
  604|      4|{
  605|      4|	char *expanded, *ret, cwd[PATH_MAX];
  606|       |
  607|      4|	if (strcasecmp(path, "none") == 0)
  ------------------
  |  Branch (607:6): [True: 0, False: 4]
  ------------------
  608|      0|		return xstrdup("none");
  609|      4|	expanded = tilde_expand_filename(path, getuid());
  610|      4|	if (path_absolute(expanded))
  ------------------
  |  Branch (610:6): [True: 4, False: 0]
  ------------------
  611|      4|		return expanded;
  612|      0|	if (getcwd(cwd, sizeof(cwd)) == NULL)
  ------------------
  |  Branch (612:6): [True: 0, False: 0]
  ------------------
  613|      0|		fatal_f("getcwd: %s", strerror(errno));
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  614|      0|	xasprintf(&ret, "%s/%s", cwd, expanded);
  615|      0|	free(expanded);
  616|      0|	return ret;
  617|      0|}
servconf.c:assemble_algorithms:
  207|      1|{
  208|      1|	char *all_cipher, *all_mac, *all_kex, *all_key, *all_sig;
  209|      1|	char *def_cipher, *def_mac, *def_kex, *def_key, *def_sig;
  210|      1|	int r;
  211|       |
  212|      1|	all_cipher = cipher_alg_list(',', 0);
  213|      1|	all_mac = mac_alg_list(',');
  214|      1|	all_kex = kex_alg_list(',');
  215|      1|	all_key = sshkey_alg_list(0, 0, 1, ',');
  216|      1|	all_sig = sshkey_alg_list(0, 1, 1, ',');
  217|       |	/* remove unsupported algos from default lists */
  218|      1|	def_cipher = match_filter_allowlist(KEX_SERVER_ENCRYPT, all_cipher);
  ------------------
  |  |   66|      1|	"chacha20-poly1305@openssh.com," \
  |  |   67|      1|	"aes128-gcm@openssh.com,aes256-gcm@openssh.com," \
  |  |   68|      1|	"aes128-ctr,aes192-ctr,aes256-ctr"
  ------------------
  219|      1|	def_mac = match_filter_allowlist(KEX_SERVER_MAC, all_mac);
  ------------------
  |  |   73|      1|	"umac-64-etm@openssh.com," \
  |  |   74|      1|	"umac-128-etm@openssh.com," \
  |  |   75|      1|	"hmac-sha2-256-etm@openssh.com," \
  |  |   76|      1|	"hmac-sha2-512-etm@openssh.com," \
  |  |   77|      1|	"hmac-sha1-etm@openssh.com," \
  |  |   78|      1|	"umac-64@openssh.com," \
  |  |   79|      1|	"umac-128@openssh.com," \
  |  |   80|      1|	"hmac-sha2-256," \
  |  |   81|      1|	"hmac-sha2-512," \
  |  |   82|      1|	"hmac-sha1"
  ------------------
  220|      1|	def_kex = match_filter_allowlist(KEX_SERVER_KEX, all_kex);
  ------------------
  |  |   28|      1|	"mlkem768x25519-sha256," \
  |  |   29|      1|	"sntrup761x25519-sha512," \
  |  |   30|      1|	"sntrup761x25519-sha512@openssh.com," \
  |  |   31|      1|	"curve25519-sha256," \
  |  |   32|      1|	"curve25519-sha256@libssh.org," \
  |  |   33|      1|	"ecdh-sha2-nistp256," \
  |  |   34|      1|	"ecdh-sha2-nistp384," \
  |  |   35|      1|	"ecdh-sha2-nistp521" \
  ------------------
  221|      1|	def_key = match_filter_allowlist(KEX_DEFAULT_PK_ALG, all_key);
  ------------------
  |  |   44|      1|	"ssh-ed25519-cert-v01@openssh.com," \
  |  |   45|      1|	"ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |   46|      1|	"ecdsa-sha2-nistp384-cert-v01@openssh.com," \
  |  |   47|      1|	"ecdsa-sha2-nistp521-cert-v01@openssh.com," \
  |  |   48|      1|	"sk-ssh-ed25519-cert-v01@openssh.com," \
  |  |   49|      1|	"sk-ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |   50|      1|	"webauthn-sk-ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |   51|      1|	"rsa-sha2-512-cert-v01@openssh.com," \
  |  |   52|      1|	"rsa-sha2-256-cert-v01@openssh.com," \
  |  |   53|      1|	"ssh-mldsa44-ed25519-cert," \
  |  |   54|      1|	"ssh-ed25519," \
  |  |   55|      1|	"ecdsa-sha2-nistp256," \
  |  |   56|      1|	"ecdsa-sha2-nistp384," \
  |  |   57|      1|	"ecdsa-sha2-nistp521," \
  |  |   58|      1|	"sk-ssh-ed25519@openssh.com," \
  |  |   59|      1|	"sk-ecdsa-sha2-nistp256@openssh.com," \
  |  |   60|      1|	"webauthn-sk-ecdsa-sha2-nistp256@openssh.com," \
  |  |   61|      1|	"rsa-sha2-512," \
  |  |   62|      1|	"rsa-sha2-256," \
  |  |   63|      1|	"ssh-mldsa44-ed25519"
  ------------------
  222|      1|	def_sig = match_filter_allowlist(SSH_ALLOWED_CA_SIGALGS, all_sig);
  ------------------
  |  |   88|      1|	"ssh-ed25519," \
  |  |   89|      1|	"ecdsa-sha2-nistp256," \
  |  |   90|      1|	"ecdsa-sha2-nistp384," \
  |  |   91|      1|	"ecdsa-sha2-nistp521," \
  |  |   92|      1|	"sk-ssh-ed25519@openssh.com," \
  |  |   93|      1|	"sk-ecdsa-sha2-nistp256@openssh.com," \
  |  |   94|      1|	"webauthn-sk-ecdsa-sha2-nistp256@openssh.com," \
  |  |   95|      1|	"rsa-sha2-512," \
  |  |   96|      1|	"rsa-sha2-256," \
  |  |   97|      1|	"ssh-mldsa44-ed25519"
  ------------------
  223|      1|#define ASSEMBLE(what, defaults, all) \
  224|      1|	do { \
  225|      1|		if ((r = kex_assemble_names(&o->what, defaults, all)) != 0) \
  226|      1|			fatal_fr(r, "%s", #what); \
  227|      1|	} while (0)
  228|      1|	ASSEMBLE(ciphers, def_cipher, all_cipher);
  ------------------
  |  |  224|      1|	do { \
  |  |  225|      1|		if ((r = kex_assemble_names(&o->what, defaults, all)) != 0) \
  |  |  ------------------
  |  |  |  Branch (225:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  226|      1|			fatal_fr(r, "%s", #what); \
  |  |  ------------------
  |  |  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  |  |  ------------------
  |  |  227|      1|	} while (0)
  |  |  ------------------
  |  |  |  Branch (227:11): [Folded, False: 1]
  |  |  ------------------
  ------------------
  229|      1|	ASSEMBLE(macs, def_mac, all_mac);
  ------------------
  |  |  224|      1|	do { \
  |  |  225|      1|		if ((r = kex_assemble_names(&o->what, defaults, all)) != 0) \
  |  |  ------------------
  |  |  |  Branch (225:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  226|      1|			fatal_fr(r, "%s", #what); \
  |  |  ------------------
  |  |  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  |  |  ------------------
  |  |  227|      1|	} while (0)
  |  |  ------------------
  |  |  |  Branch (227:11): [Folded, False: 1]
  |  |  ------------------
  ------------------
  230|      1|	ASSEMBLE(kex_algorithms, def_kex, all_kex);
  ------------------
  |  |  224|      1|	do { \
  |  |  225|      1|		if ((r = kex_assemble_names(&o->what, defaults, all)) != 0) \
  |  |  ------------------
  |  |  |  Branch (225:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  226|      1|			fatal_fr(r, "%s", #what); \
  |  |  ------------------
  |  |  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  |  |  ------------------
  |  |  227|      1|	} while (0)
  |  |  ------------------
  |  |  |  Branch (227:11): [Folded, False: 1]
  |  |  ------------------
  ------------------
  231|      1|	ASSEMBLE(hostkeyalgorithms, def_key, all_key);
  ------------------
  |  |  224|      1|	do { \
  |  |  225|      1|		if ((r = kex_assemble_names(&o->what, defaults, all)) != 0) \
  |  |  ------------------
  |  |  |  Branch (225:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  226|      1|			fatal_fr(r, "%s", #what); \
  |  |  ------------------
  |  |  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  |  |  ------------------
  |  |  227|      1|	} while (0)
  |  |  ------------------
  |  |  |  Branch (227:11): [Folded, False: 1]
  |  |  ------------------
  ------------------
  232|      1|	ASSEMBLE(hostbased_accepted_algos, def_key, all_key);
  ------------------
  |  |  224|      1|	do { \
  |  |  225|      1|		if ((r = kex_assemble_names(&o->what, defaults, all)) != 0) \
  |  |  ------------------
  |  |  |  Branch (225:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  226|      1|			fatal_fr(r, "%s", #what); \
  |  |  ------------------
  |  |  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  |  |  ------------------
  |  |  227|      1|	} while (0)
  |  |  ------------------
  |  |  |  Branch (227:11): [Folded, False: 1]
  |  |  ------------------
  ------------------
  233|      1|	ASSEMBLE(pubkey_accepted_algos, def_key, all_key);
  ------------------
  |  |  224|      1|	do { \
  |  |  225|      1|		if ((r = kex_assemble_names(&o->what, defaults, all)) != 0) \
  |  |  ------------------
  |  |  |  Branch (225:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  226|      1|			fatal_fr(r, "%s", #what); \
  |  |  ------------------
  |  |  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  |  |  ------------------
  |  |  227|      1|	} while (0)
  |  |  ------------------
  |  |  |  Branch (227:11): [Folded, False: 1]
  |  |  ------------------
  ------------------
  234|      1|	ASSEMBLE(ca_sign_algorithms, def_sig, all_sig);
  ------------------
  |  |  224|      1|	do { \
  |  |  225|      1|		if ((r = kex_assemble_names(&o->what, defaults, all)) != 0) \
  |  |  ------------------
  |  |  |  Branch (225:7): [True: 0, False: 1]
  |  |  ------------------
  |  |  226|      1|			fatal_fr(r, "%s", #what); \
  |  |  ------------------
  |  |  |  |  146|      0|#define fatal_fr(r, ...)	sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), __VA_ARGS__)
  |  |  ------------------
  |  |  227|      1|	} while (0)
  |  |  ------------------
  |  |  |  Branch (227:11): [Folded, False: 1]
  |  |  ------------------
  ------------------
  235|      1|#undef ASSEMBLE
  236|      1|	free(all_cipher);
  237|      1|	free(all_mac);
  238|      1|	free(all_kex);
  239|      1|	free(all_key);
  240|      1|	free(all_sig);
  241|      1|	free(def_cipher);
  242|      1|	free(def_mac);
  243|      1|	free(def_kex);
  244|      1|	free(def_key);
  245|      1|	free(def_sig);
  246|      1|}
servconf.c:option_clear_or_none:
  201|     16|{
  202|     16|	return o == NULL || strcasecmp(o, "none") == 0;
  ------------------
  |  Branch (202:9): [True: 8, False: 8]
  |  Branch (202:22): [True: 0, False: 8]
  ------------------
  203|     16|}
servconf.c:add_listen_addr:
  622|      1|{
  623|      1|	u_int i;
  624|       |
  625|      1|	if (port > 0)
  ------------------
  |  Branch (625:6): [True: 0, False: 1]
  ------------------
  626|      0|		add_one_listen_addr(options, addr, rdomain, port);
  627|      1|	else {
  628|      2|		for (i = 0; i < options->num_ports; i++) {
  ------------------
  |  Branch (628:15): [True: 1, False: 1]
  ------------------
  629|      1|			add_one_listen_addr(options, addr, rdomain,
  630|      1|			    options->ports[i]);
  631|      1|		}
  632|      1|	}
  633|      1|}
servconf.c:add_one_listen_addr:
  638|      1|{
  639|      1|	struct addrinfo hints, *ai, *aitop;
  640|      1|	char strport[NI_MAXSERV];
  641|      1|	int gaierr;
  642|      1|	u_int i;
  643|       |
  644|       |	/* Find listen_addrs entry for this rdomain */
  645|      1|	for (i = 0; i < options->num_listen_addrs; i++) {
  ------------------
  |  Branch (645:14): [True: 0, False: 1]
  ------------------
  646|      0|		if (rdomain == NULL && options->listen_addrs[i].rdomain == NULL)
  ------------------
  |  Branch (646:7): [True: 0, False: 0]
  |  Branch (646:26): [True: 0, False: 0]
  ------------------
  647|      0|			break;
  648|      0|		if (rdomain == NULL || options->listen_addrs[i].rdomain == NULL)
  ------------------
  |  Branch (648:7): [True: 0, False: 0]
  |  Branch (648:26): [True: 0, False: 0]
  ------------------
  649|      0|			continue;
  650|      0|		if (strcmp(rdomain, options->listen_addrs[i].rdomain) == 0)
  ------------------
  |  Branch (650:7): [True: 0, False: 0]
  ------------------
  651|      0|			break;
  652|      0|	}
  653|      1|	if (i >= options->num_listen_addrs) {
  ------------------
  |  Branch (653:6): [True: 1, False: 0]
  ------------------
  654|       |		/* No entry for this rdomain; allocate one */
  655|      1|		if (i >= INT_MAX)
  ------------------
  |  Branch (655:7): [True: 0, False: 1]
  ------------------
  656|      0|			fatal_f("too many listen addresses");
  ------------------
  |  |  126|      0|#define fatal_f(...)		sshfatal(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  657|      1|		options->listen_addrs = xrecallocarray(options->listen_addrs,
  658|      1|		    options->num_listen_addrs, options->num_listen_addrs + 1,
  659|      1|		    sizeof(*options->listen_addrs));
  660|      1|		i = options->num_listen_addrs++;
  661|      1|		if (rdomain != NULL)
  ------------------
  |  Branch (661:7): [True: 0, False: 1]
  ------------------
  662|      0|			options->listen_addrs[i].rdomain = xstrdup(rdomain);
  663|      1|	}
  664|       |	/* options->listen_addrs[i] points to the addresses for this rdomain */
  665|       |
  666|      1|	memset(&hints, 0, sizeof(hints));
  667|      1|	hints.ai_family = options->address_family;
  668|      1|	hints.ai_socktype = SOCK_STREAM;
  669|      1|	hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0;
  ------------------
  |  Branch (669:19): [True: 1, False: 0]
  ------------------
  670|      1|	snprintf(strport, sizeof strport, "%d", port);
  671|      1|	if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
  ------------------
  |  Branch (671:6): [True: 0, False: 1]
  ------------------
  672|      0|		fatal("bad addr or host: %s (%s)",
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (115:89): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  673|      1|		    addr ? addr : "<NULL>",
  674|      1|		    ssh_gai_strerror(gaierr));
  675|      2|	for (ai = aitop; ai->ai_next; ai = ai->ai_next)
  ------------------
  |  Branch (675:19): [True: 1, False: 1]
  ------------------
  676|      1|		;
  677|      1|	ai->ai_next = options->listen_addrs[i].addrs;
  678|      1|	options->listen_addrs[i].addrs = aitop;
  679|      1|}

crypto_scalarmult_curve25519:
  250|      4|{
  251|      4|  unsigned int work[96];
  252|      4|  unsigned char e[32];
  253|      4|  unsigned int i;
  254|    132|  for (i = 0;i < 32;++i) e[i] = n[i];
  ------------------
  |  Branch (254:14): [True: 128, False: 4]
  ------------------
  255|      4|  e[0] &= 248;
  256|      4|  e[31] &= 127;
  257|      4|  e[31] |= 64;
  258|    132|  for (i = 0;i < 32;++i) work[i] = p[i];
  ------------------
  |  Branch (258:14): [True: 128, False: 4]
  ------------------
  259|      4|  mainloop(work,e);
  260|      4|  recip(work + 32,work + 32);
  261|      4|  mult(work + 64,work,work + 32);
  262|      4|  freeze(work + 64);
  263|    132|  for (i = 0;i < 32;++i) q[i] = work[64 + i];
  ------------------
  |  Branch (263:14): [True: 128, False: 4]
  ------------------
  264|      4|  return 0;
  265|      4|}
smult_curve25519_ref.c:mainloop:
  125|      4|{
  126|      4|  unsigned int xzm1[64];
  127|      4|  unsigned int xzm[64];
  128|      4|  unsigned int xzmb[64];
  129|      4|  unsigned int xzm1b[64];
  130|      4|  unsigned int xznb[64];
  131|      4|  unsigned int xzn1b[64];
  132|      4|  unsigned int a0[64];
  133|      4|  unsigned int a1[64];
  134|      4|  unsigned int b0[64];
  135|      4|  unsigned int b1[64];
  136|      4|  unsigned int c1[64];
  137|      4|  unsigned int r[32];
  138|      4|  unsigned int s[32];
  139|      4|  unsigned int t[32];
  140|      4|  unsigned int u[32];
  141|      4|  unsigned int j;
  142|      4|  unsigned int b;
  143|      4|  int pos;
  144|       |
  145|    132|  for (j = 0;j < 32;++j) xzm1[j] = work[j];
  ------------------
  |  Branch (145:14): [True: 128, False: 4]
  ------------------
  146|      4|  xzm1[32] = 1;
  147|    128|  for (j = 33;j < 64;++j) xzm1[j] = 0;
  ------------------
  |  Branch (147:15): [True: 124, False: 4]
  ------------------
  148|       |
  149|      4|  xzm[0] = 1;
  150|    256|  for (j = 1;j < 64;++j) xzm[j] = 0;
  ------------------
  |  Branch (150:14): [True: 252, False: 4]
  ------------------
  151|       |
  152|  1.02k|  for (pos = 254;pos >= 0;--pos) {
  ------------------
  |  Branch (152:18): [True: 1.02k, False: 4]
  ------------------
  153|  1.02k|    b = e[pos / 8] >> (pos & 7);
  154|  1.02k|    b &= 1;
  155|  1.02k|    select(xzmb,xzm1b,xzm,xzm1,b);
  156|  1.02k|    add(a0,xzmb,xzmb + 32);
  157|  1.02k|    sub(a0 + 32,xzmb,xzmb + 32);
  158|  1.02k|    add(a1,xzm1b,xzm1b + 32);
  159|  1.02k|    sub(a1 + 32,xzm1b,xzm1b + 32);
  160|  1.02k|    square(b0,a0);
  161|  1.02k|    square(b0 + 32,a0 + 32);
  162|  1.02k|    mult(b1,a1,a0 + 32);
  163|  1.02k|    mult(b1 + 32,a1 + 32,a0);
  164|  1.02k|    add(c1,b1,b1 + 32);
  165|  1.02k|    sub(c1 + 32,b1,b1 + 32);
  166|  1.02k|    square(r,c1 + 32);
  167|  1.02k|    sub(s,b0,b0 + 32);
  168|  1.02k|    mult121665(t,s);
  169|  1.02k|    add(u,t,b0);
  170|  1.02k|    mult(xznb,b0,b0 + 32);
  171|  1.02k|    mult(xznb + 32,s,u);
  172|  1.02k|    square(xzn1b,c1);
  173|  1.02k|    mult(xzn1b + 32,r,work);
  174|  1.02k|    select(xzm,xzm1,xznb,xzn1b,b);
  175|  1.02k|  }
  176|       |
  177|    260|  for (j = 0;j < 64;++j) work[j] = xzm[j];
  ------------------
  |  Branch (177:14): [True: 256, False: 4]
  ------------------
  178|      4|}
smult_curve25519_ref.c:select:
  111|  2.04k|{
  112|  2.04k|  unsigned int j;
  113|  2.04k|  unsigned int t;
  114|  2.04k|  unsigned int bminus1;
  115|       |
  116|  2.04k|  bminus1 = b - 1;
  117|   132k|  for (j = 0;j < 64;++j) {
  ------------------
  |  Branch (117:14): [True: 130k, False: 2.04k]
  ------------------
  118|   130k|    t = bminus1 & (r[j] ^ s[j]);
  119|   130k|    p[j] = s[j] ^ t;
  120|   130k|    q[j] = r[j] ^ t;
  121|   130k|  }
  122|  2.04k|}
smult_curve25519_ref.c:add:
   12|  4.08k|{
   13|  4.08k|  unsigned int j;
   14|  4.08k|  unsigned int u;
   15|  4.08k|  u = 0;
   16|   130k|  for (j = 0;j < 31;++j) { u += a[j] + b[j]; out[j] = u & 255; u >>= 8; }
  ------------------
  |  Branch (16:14): [True: 126k, False: 4.08k]
  ------------------
   17|  4.08k|  u += a[31] + b[31]; out[31] = u;
   18|  4.08k|}
smult_curve25519_ref.c:sub:
   21|  4.08k|{
   22|  4.08k|  unsigned int j;
   23|  4.08k|  unsigned int u;
   24|  4.08k|  u = 218;
   25|   130k|  for (j = 0;j < 31;++j) {
  ------------------
  |  Branch (25:14): [True: 126k, False: 4.08k]
  ------------------
   26|   126k|    u += a[j] + 65280 - b[j];
   27|   126k|    out[j] = u & 255;
   28|   126k|    u >>= 8;
   29|   126k|  }
   30|  4.08k|  u += a[31] - b[31];
   31|  4.08k|  out[31] = u;
   32|  4.08k|}
smult_curve25519_ref.c:square:
   91|  5.09k|{
   92|  5.09k|  unsigned int i;
   93|  5.09k|  unsigned int j;
   94|  5.09k|  unsigned int u;
   95|       |
   96|   168k|  for (i = 0;i < 32;++i) {
  ------------------
  |  Branch (96:14): [True: 163k, False: 5.09k]
  ------------------
   97|   163k|    u = 0;
   98|  1.46M|    for (j = 0;j < i - j;++j) u += a[j] * a[i - j];
  ------------------
  |  Branch (98:16): [True: 1.30M, False: 163k]
  ------------------
   99|  1.38M|    for (j = i + 1;j < i + 32 - j;++j) u += 38 * a[j] * a[i + 32 - j];
  ------------------
  |  Branch (99:20): [True: 1.22M, False: 163k]
  ------------------
  100|   163k|    u *= 2;
  101|   163k|    if ((i & 1) == 0) {
  ------------------
  |  Branch (101:9): [True: 81.5k, False: 81.5k]
  ------------------
  102|  81.5k|      u += a[i / 2] * a[i / 2];
  103|  81.5k|      u += 38 * a[i / 2 + 16] * a[i / 2 + 16];
  104|  81.5k|    }
  105|   163k|    out[i] = u;
  106|   163k|  }
  107|  5.09k|  squeeze(out);
  108|  5.09k|}
smult_curve25519_ref.c:squeeze:
   35|  10.2k|{
   36|  10.2k|  unsigned int j;
   37|  10.2k|  unsigned int u;
   38|  10.2k|  u = 0;
   39|   327k|  for (j = 0;j < 31;++j) { u += a[j]; a[j] = u & 255; u >>= 8; }
  ------------------
  |  Branch (39:14): [True: 317k, False: 10.2k]
  ------------------
   40|  10.2k|  u += a[31]; a[31] = u & 127;
   41|  10.2k|  u = 19 * (u >> 7);
   42|   327k|  for (j = 0;j < 31;++j) { u += a[j]; a[j] = u & 255; u >>= 8; }
  ------------------
  |  Branch (42:14): [True: 317k, False: 10.2k]
  ------------------
   43|  10.2k|  u += a[31]; a[31] = u;
   44|  10.2k|}
smult_curve25519_ref.c:mult121665:
   78|  1.02k|{
   79|  1.02k|  unsigned int j;
   80|  1.02k|  unsigned int u;
   81|       |
   82|  1.02k|  u = 0;
   83|  32.6k|  for (j = 0;j < 31;++j) { u += 121665 * a[j]; out[j] = u & 255; u >>= 8; }
  ------------------
  |  Branch (83:14): [True: 31.6k, False: 1.02k]
  ------------------
   84|  1.02k|  u += 121665 * a[31]; out[31] = u & 127;
   85|  1.02k|  u = 19 * (u >> 7);
   86|  32.6k|  for (j = 0;j < 31;++j) { u += out[j]; out[j] = u & 255; u >>= 8; }
  ------------------
  |  Branch (86:14): [True: 31.6k, False: 1.02k]
  ------------------
   87|  1.02k|  u += out[j]; out[j] = u;
   88|  1.02k|}
smult_curve25519_ref.c:recip:
  181|      4|{
  182|      4|  unsigned int z2[32];
  183|      4|  unsigned int z9[32];
  184|      4|  unsigned int z11[32];
  185|      4|  unsigned int z2_5_0[32];
  186|      4|  unsigned int z2_10_0[32];
  187|      4|  unsigned int z2_20_0[32];
  188|      4|  unsigned int z2_50_0[32];
  189|      4|  unsigned int z2_100_0[32];
  190|      4|  unsigned int t0[32];
  191|      4|  unsigned int t1[32];
  192|      4|  int i;
  193|       |
  194|       |  /* 2 */ square(z2,z);
  195|      4|  /* 4 */ square(t1,z2);
  196|      4|  /* 8 */ square(t0,t1);
  197|      4|  /* 9 */ mult(z9,t0,z);
  198|      4|  /* 11 */ mult(z11,z9,z2);
  199|      4|  /* 22 */ square(t0,z11);
  200|      4|  /* 2^5 - 2^0 = 31 */ mult(z2_5_0,t0,z9);
  201|       |
  202|       |  /* 2^6 - 2^1 */ square(t0,z2_5_0);
  203|      4|  /* 2^7 - 2^2 */ square(t1,t0);
  204|      4|  /* 2^8 - 2^3 */ square(t0,t1);
  205|      4|  /* 2^9 - 2^4 */ square(t1,t0);
  206|      4|  /* 2^10 - 2^5 */ square(t0,t1);
  207|      4|  /* 2^10 - 2^0 */ mult(z2_10_0,t0,z2_5_0);
  208|       |
  209|       |  /* 2^11 - 2^1 */ square(t0,z2_10_0);
  210|      4|  /* 2^12 - 2^2 */ square(t1,t0);
  211|     20|  /* 2^20 - 2^10 */ for (i = 2;i < 10;i += 2) { square(t0,t1); square(t1,t0); }
  ------------------
  |  Branch (211:32): [True: 16, False: 4]
  ------------------
  212|      4|  /* 2^20 - 2^0 */ mult(z2_20_0,t1,z2_10_0);
  213|       |
  214|       |  /* 2^21 - 2^1 */ square(t0,z2_20_0);
  215|      4|  /* 2^22 - 2^2 */ square(t1,t0);
  216|     40|  /* 2^40 - 2^20 */ for (i = 2;i < 20;i += 2) { square(t0,t1); square(t1,t0); }
  ------------------
  |  Branch (216:32): [True: 36, False: 4]
  ------------------
  217|      4|  /* 2^40 - 2^0 */ mult(t0,t1,z2_20_0);
  218|       |
  219|       |  /* 2^41 - 2^1 */ square(t1,t0);
  220|      4|  /* 2^42 - 2^2 */ square(t0,t1);
  221|     20|  /* 2^50 - 2^10 */ for (i = 2;i < 10;i += 2) { square(t1,t0); square(t0,t1); }
  ------------------
  |  Branch (221:32): [True: 16, False: 4]
  ------------------
  222|      4|  /* 2^50 - 2^0 */ mult(z2_50_0,t0,z2_10_0);
  223|       |
  224|       |  /* 2^51 - 2^1 */ square(t0,z2_50_0);
  225|      4|  /* 2^52 - 2^2 */ square(t1,t0);
  226|    100|  /* 2^100 - 2^50 */ for (i = 2;i < 50;i += 2) { square(t0,t1); square(t1,t0); }
  ------------------
  |  Branch (226:33): [True: 96, False: 4]
  ------------------
  227|      4|  /* 2^100 - 2^0 */ mult(z2_100_0,t1,z2_50_0);
  228|       |
  229|       |  /* 2^101 - 2^1 */ square(t1,z2_100_0);
  230|      4|  /* 2^102 - 2^2 */ square(t0,t1);
  231|    200|  /* 2^200 - 2^100 */ for (i = 2;i < 100;i += 2) { square(t1,t0); square(t0,t1); }
  ------------------
  |  Branch (231:34): [True: 196, False: 4]
  ------------------
  232|      4|  /* 2^200 - 2^0 */ mult(t1,t0,z2_100_0);
  233|       |
  234|       |  /* 2^201 - 2^1 */ square(t0,t1);
  235|      4|  /* 2^202 - 2^2 */ square(t1,t0);
  236|    100|  /* 2^250 - 2^50 */ for (i = 2;i < 50;i += 2) { square(t0,t1); square(t1,t0); }
  ------------------
  |  Branch (236:33): [True: 96, False: 4]
  ------------------
  237|      4|  /* 2^250 - 2^0 */ mult(t0,t1,z2_50_0);
  238|       |
  239|       |  /* 2^251 - 2^1 */ square(t1,t0);
  240|      4|  /* 2^252 - 2^2 */ square(t0,t1);
  241|      4|  /* 2^253 - 2^3 */ square(t1,t0);
  242|      4|  /* 2^254 - 2^4 */ square(t0,t1);
  243|      4|  /* 2^255 - 2^5 */ square(t1,t0);
  244|      4|  /* 2^255 - 21 */ mult(out,t1,z11);
  245|      4|}
smult_curve25519_ref.c:mult:
   63|  5.14k|{
   64|  5.14k|  unsigned int i;
   65|  5.14k|  unsigned int j;
   66|  5.14k|  unsigned int u;
   67|       |
   68|   169k|  for (i = 0;i < 32;++i) {
  ------------------
  |  Branch (68:14): [True: 164k, False: 5.14k]
  ------------------
   69|   164k|    u = 0;
   70|  2.88M|    for (j = 0;j <= i;++j) u += a[j] * b[i - j];
  ------------------
  |  Branch (70:16): [True: 2.71M, False: 164k]
  ------------------
   71|  2.71M|    for (j = i + 1;j < 32;++j) u += 38 * a[j] * b[i + 32 - j];
  ------------------
  |  Branch (71:20): [True: 2.55M, False: 164k]
  ------------------
   72|   164k|    out[i] = u;
   73|   164k|  }
   74|  5.14k|  squeeze(out);
   75|  5.14k|}
smult_curve25519_ref.c:freeze:
   51|      4|{
   52|      4|  unsigned int aorig[32];
   53|      4|  unsigned int j;
   54|      4|  unsigned int negative;
   55|       |
   56|    132|  for (j = 0;j < 32;++j) aorig[j] = a[j];
  ------------------
  |  Branch (56:14): [True: 128, False: 4]
  ------------------
   57|      4|  add(a,a,minusp);
   58|      4|  negative = -((a[31] >> 7) & 1);
   59|    132|  for (j = 0;j < 32;++j) a[j] ^= negative & (aorig[j] ^ a[j]);
  ------------------
  |  Branch (59:14): [True: 128, False: 4]
  ------------------
   60|      4|}

ssh_ed25519_encode_store_sig:
  184|      1|{
  185|      1|	struct sshbuf *b = NULL;
  186|      1|	int r = -1;
  187|      1|	size_t len;
  188|       |
  189|      1|	if (lenp != NULL)
  ------------------
  |  Branch (189:6): [True: 1, False: 0]
  ------------------
  190|      1|		*lenp = 0;
  191|      1|	if (sigp != NULL)
  ------------------
  |  Branch (191:6): [True: 1, False: 0]
  ------------------
  192|      1|		*sigp = NULL;
  193|       |
  194|      1|	if (slen != crypto_sign_ed25519_BYTES)
  ------------------
  |  |   62|      1|#define crypto_sign_ed25519_BYTES 64U
  ------------------
  |  Branch (194:6): [True: 0, False: 1]
  ------------------
  195|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  196|       |
  197|       |	/* encode signature */
  198|      1|	if ((b = sshbuf_new()) == NULL) {
  ------------------
  |  Branch (198:6): [True: 0, False: 1]
  ------------------
  199|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  200|      0|		goto out;
  201|      0|	}
  202|      1|	if ((r = sshbuf_put_cstring(b, "ssh-ed25519")) != 0 ||
  ------------------
  |  Branch (202:6): [True: 0, False: 1]
  ------------------
  203|      1|	    (r = sshbuf_put_string(b, sig, slen)) != 0)
  ------------------
  |  Branch (203:6): [True: 0, False: 1]
  ------------------
  204|      0|		goto out;
  205|      1|	len = sshbuf_len(b);
  206|      1|	if (sigp != NULL) {
  ------------------
  |  Branch (206:6): [True: 1, False: 0]
  ------------------
  207|      1|		if ((*sigp = malloc(len)) == NULL) {
  ------------------
  |  Branch (207:7): [True: 0, False: 1]
  ------------------
  208|      0|			r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  209|      0|			goto out;
  210|      0|		}
  211|      1|		memcpy(*sigp, sshbuf_ptr(b), len);
  212|      1|	}
  213|      1|	if (lenp != NULL)
  ------------------
  |  Branch (213:6): [True: 1, False: 0]
  ------------------
  214|      1|		*lenp = len;
  215|       |	/* success */
  216|      1|	r = 0;
  217|      1| out:
  218|      1|	sshbuf_free(b);
  219|      1|	return r;
  220|      1|}
ssh-ed25519.c:ssh_ed25519_cleanup:
   36|      1|{
   37|      1|	freezero(k->ed25519_pk, ED25519_PK_SZ);
  ------------------
  |  |  141|      1|#define	ED25519_PK_SZ	crypto_sign_ed25519_PUBLICKEYBYTES
  |  |  ------------------
  |  |  |  |   60|      1|#define crypto_sign_ed25519_PUBLICKEYBYTES 32U
  |  |  ------------------
  ------------------
   38|      1|	freezero(k->ed25519_sk, ED25519_SK_SZ);
  ------------------
  |  |  140|      1|#define	ED25519_SK_SZ	crypto_sign_ed25519_SECRETKEYBYTES
  |  |  ------------------
  |  |  |  |   59|      1|#define crypto_sign_ed25519_SECRETKEYBYTES 64U
  |  |  ------------------
  ------------------
   39|      1|	k->ed25519_pk = NULL;
   40|       |	k->ed25519_sk = NULL;
   41|      1|}
ssh-ed25519.c:ssh_ed25519_equal:
   45|      2|{
   46|      2|	if (a->ed25519_pk == NULL || b->ed25519_pk == NULL)
  ------------------
  |  Branch (46:6): [True: 0, False: 2]
  |  Branch (46:31): [True: 0, False: 2]
  ------------------
   47|      0|		return 0;
   48|      2|	if (memcmp(a->ed25519_pk, b->ed25519_pk, ED25519_PK_SZ) != 0)
  ------------------
  |  |  141|      2|#define	ED25519_PK_SZ	crypto_sign_ed25519_PUBLICKEYBYTES
  |  |  ------------------
  |  |  |  |   60|      2|#define crypto_sign_ed25519_PUBLICKEYBYTES 32U
  |  |  ------------------
  ------------------
  |  Branch (48:6): [True: 0, False: 2]
  ------------------
   49|      0|		return 0;
   50|      2|	return 1;
   51|      2|}
ssh-ed25519.c:ssh_ed25519_serialize_public:
   56|      1|{
   57|      1|	int r;
   58|       |
   59|      1|	if (key->ed25519_pk == NULL)
  ------------------
  |  Branch (59:6): [True: 0, False: 1]
  ------------------
   60|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
   61|      1|	if ((r = sshbuf_put_string(b, key->ed25519_pk, ED25519_PK_SZ)) != 0)
  ------------------
  |  |  141|      1|#define	ED25519_PK_SZ	crypto_sign_ed25519_PUBLICKEYBYTES
  |  |  ------------------
  |  |  |  |   60|      1|#define crypto_sign_ed25519_PUBLICKEYBYTES 32U
  |  |  ------------------
  ------------------
  |  Branch (61:6): [True: 0, False: 1]
  ------------------
   62|      0|		return r;
   63|       |
   64|      1|	return 0;
   65|      1|}
ssh-ed25519.c:ssh_ed25519_deserialize_public:
  105|      4|{
  106|      4|	u_char *pk = NULL;
  107|      4|	size_t len = 0;
  108|      4|	int r;
  109|       |
  110|      4|	if ((r = sshbuf_get_string(b, &pk, &len)) != 0)
  ------------------
  |  Branch (110:6): [True: 0, False: 4]
  ------------------
  111|      0|		return r;
  112|      4|	if (len != ED25519_PK_SZ) {
  ------------------
  |  |  141|      4|#define	ED25519_PK_SZ	crypto_sign_ed25519_PUBLICKEYBYTES
  |  |  ------------------
  |  |  |  |   60|      4|#define crypto_sign_ed25519_PUBLICKEYBYTES 32U
  |  |  ------------------
  ------------------
  |  Branch (112:6): [True: 0, False: 4]
  ------------------
  113|      0|		freezero(pk, len);
  114|      0|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  115|      0|	}
  116|      4|	key->ed25519_pk = pk;
  117|      4|	return 0;
  118|      4|}
ssh-ed25519.c:ssh_ed25519_deserialize_private:
  123|      1|{
  124|      1|	int r;
  125|      1|	size_t sklen = 0;
  126|      1|	u_char *ed25519_sk = NULL;
  127|       |
  128|      1|	if ((r = ssh_ed25519_deserialize_public(NULL, b, key)) != 0)
  ------------------
  |  Branch (128:6): [True: 0, False: 1]
  ------------------
  129|      0|		goto out;
  130|      1|	if ((r = sshbuf_get_string(b, &ed25519_sk, &sklen)) != 0)
  ------------------
  |  Branch (130:6): [True: 0, False: 1]
  ------------------
  131|      0|		goto out;
  132|      1|	if (sklen != ED25519_SK_SZ) {
  ------------------
  |  |  140|      1|#define	ED25519_SK_SZ	crypto_sign_ed25519_SECRETKEYBYTES
  |  |  ------------------
  |  |  |  |   59|      1|#define crypto_sign_ed25519_SECRETKEYBYTES 64U
  |  |  ------------------
  ------------------
  |  Branch (132:6): [True: 0, False: 1]
  ------------------
  133|      0|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  134|      0|		goto out;
  135|      0|	}
  136|      1|	key->ed25519_sk = ed25519_sk;
  137|      1|	ed25519_sk = NULL; /* transferred */
  138|       |	/* success */
  139|      1|	r = 0;
  140|      1| out:
  141|      1|	freezero(ed25519_sk, sklen);
  142|      1|	return r;
  143|      1|}
ssh-ed25519.c:ssh_ed25519_copy_public:
   93|      2|{
   94|      2|	if (from->ed25519_pk == NULL)
  ------------------
  |  Branch (94:6): [True: 0, False: 2]
  ------------------
   95|      0|		return 0; /* XXX SSH_ERR_INTERNAL_ERROR ? */
   96|      2|	if ((to->ed25519_pk = malloc(ED25519_PK_SZ)) == NULL)
  ------------------
  |  |  141|      2|#define	ED25519_PK_SZ	crypto_sign_ed25519_PUBLICKEYBYTES
  |  |  ------------------
  |  |  |  |   60|      2|#define crypto_sign_ed25519_PUBLICKEYBYTES 32U
  |  |  ------------------
  ------------------
  |  Branch (96:6): [True: 0, False: 2]
  ------------------
   97|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
   98|      2|	memcpy(to->ed25519_pk, from->ed25519_pk, ED25519_PK_SZ);
  ------------------
  |  |  141|      2|#define	ED25519_PK_SZ	crypto_sign_ed25519_PUBLICKEYBYTES
  |  |  ------------------
  |  |  |  |   60|      2|#define crypto_sign_ed25519_PUBLICKEYBYTES 32U
  |  |  ------------------
  ------------------
   99|      2|	return 0;
  100|      2|}
ssh-ed25519.c:ssh_ed25519_sign:
  150|      1|{
  151|      1|	u_char sig[crypto_sign_ed25519_BYTES];
  152|      1|	unsigned long long siglen = 0;
  153|      1|	int r, ret;
  154|       |
  155|      1|	if (lenp != NULL)
  ------------------
  |  Branch (155:6): [True: 1, False: 0]
  ------------------
  156|      1|		*lenp = 0;
  157|      1|	if (sigp != NULL)
  ------------------
  |  Branch (157:6): [True: 1, False: 0]
  ------------------
  158|      1|		*sigp = NULL;
  159|       |
  160|      1|	if (key == NULL ||
  ------------------
  |  Branch (160:6): [True: 0, False: 1]
  ------------------
  161|      1|	    sshkey_type_plain(key->type) != KEY_ED25519 ||
  ------------------
  |  Branch (161:6): [True: 0, False: 1]
  ------------------
  162|      1|	    key->ed25519_sk == NULL)
  ------------------
  |  Branch (162:6): [True: 0, False: 1]
  ------------------
  163|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  164|       |
  165|      1|	if ((ret = crypto_sign_ed25519_detached(sig, &siglen, data, datalen,
  ------------------
  |  Branch (165:6): [True: 0, False: 1]
  ------------------
  166|      1|	    key->ed25519_sk)) != 0 || siglen != sizeof(sig)) {
  ------------------
  |  Branch (166:32): [True: 0, False: 1]
  ------------------
  167|      0|		r = SSH_ERR_INVALID_ARGUMENT; /* XXX better error? */
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  168|      0|		goto out;
  169|      0|	}
  170|      1|	if ((r = ssh_ed25519_encode_store_sig(sig, siglen,
  ------------------
  |  Branch (170:6): [True: 0, False: 1]
  ------------------
  171|      1|	    sigp, lenp)) != 0)
  172|      0|		goto out;
  173|       |
  174|       |	/* success */
  175|      1|	r = 0;
  176|      1| out:
  177|      1|	explicit_bzero(sig, sizeof(sig));
  178|      1|	return r;
  179|      1|}
ssh-ed25519.c:ssh_ed25519_verify:
  227|      1|{
  228|      1|	struct sshbuf *b = NULL;
  229|      1|	char *ktype = NULL;
  230|      1|	const u_char *sigblob;
  231|      1|	size_t len;
  232|      1|	int r, ret;
  233|       |
  234|      1|	if (key == NULL ||
  ------------------
  |  Branch (234:6): [True: 0, False: 1]
  ------------------
  235|      1|	    sshkey_type_plain(key->type) != KEY_ED25519 ||
  ------------------
  |  Branch (235:6): [True: 0, False: 1]
  ------------------
  236|      1|	    key->ed25519_pk == NULL ||
  ------------------
  |  Branch (236:6): [True: 0, False: 1]
  ------------------
  237|      1|	    sig == NULL || siglen == 0)
  ------------------
  |  Branch (237:6): [True: 0, False: 1]
  |  Branch (237:21): [True: 0, False: 1]
  ------------------
  238|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  239|       |
  240|      1|	if ((b = sshbuf_from(sig, siglen)) == NULL)
  ------------------
  |  Branch (240:6): [True: 0, False: 1]
  ------------------
  241|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  242|      1|	if ((r = sshbuf_get_cstring(b, &ktype, NULL)) != 0 ||
  ------------------
  |  Branch (242:6): [True: 0, False: 1]
  ------------------
  243|      1|	    (r = sshbuf_get_string_direct(b, &sigblob, &len)) != 0)
  ------------------
  |  Branch (243:6): [True: 0, False: 1]
  ------------------
  244|      0|		goto out;
  245|      1|	if (strcmp("ssh-ed25519", ktype) != 0) {
  ------------------
  |  Branch (245:6): [True: 0, False: 1]
  ------------------
  246|      0|		r = SSH_ERR_KEY_TYPE_MISMATCH;
  ------------------
  |  |   37|      0|#define SSH_ERR_KEY_TYPE_MISMATCH		-13
  ------------------
  247|      0|		goto out;
  248|      0|	}
  249|      1|	if (sshbuf_len(b) != 0) {
  ------------------
  |  Branch (249:6): [True: 0, False: 1]
  ------------------
  250|      0|		r = SSH_ERR_UNEXPECTED_TRAILING_DATA;
  ------------------
  |  |   47|      0|#define SSH_ERR_UNEXPECTED_TRAILING_DATA	-23
  ------------------
  251|      0|		goto out;
  252|      0|	}
  253|      1|	if (len != crypto_sign_ed25519_BYTES) {
  ------------------
  |  |   62|      1|#define crypto_sign_ed25519_BYTES 64U
  ------------------
  |  Branch (253:6): [True: 0, False: 1]
  ------------------
  254|      0|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  255|      0|		goto out;
  256|      0|	}
  257|      1|	if ((ret = crypto_sign_ed25519_verify_detached(sigblob, data, dlen,
  ------------------
  |  Branch (257:6): [True: 0, False: 1]
  ------------------
  258|      1|	    key->ed25519_pk)) != 0) {
  259|      0|		debug2_f("crypto_sign_ed25519_verify_detached failed: %d", ret);
  ------------------
  |  |  121|      0|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  260|      0|	}
  261|      1|	if (ret != 0) {
  ------------------
  |  Branch (261:6): [True: 0, False: 1]
  ------------------
  262|      0|		r = SSH_ERR_SIGNATURE_INVALID;
  ------------------
  |  |   45|      0|#define SSH_ERR_SIGNATURE_INVALID		-21
  ------------------
  263|      0|		goto out;
  264|      0|	}
  265|       |	/* success */
  266|      1|	r = 0;
  267|      1| out:
  268|      1|	sshbuf_free(b);
  269|      1|	free(ktype);
  270|      1|	return r;
  271|      1|}

ssh_init:
   88|      2|{
   89|      2|	char *myproposal[PROPOSAL_MAX] = { KEX_CLIENT };
  ------------------
  |  |  103|      2|	KEX_CLIENT_KEX, \
  |  |  ------------------
  |  |  |  |   37|      2|#define KEX_CLIENT_KEX KEX_SERVER_KEX "," \
  |  |  |  |  ------------------
  |  |  |  |  |  |   28|      2|	"mlkem768x25519-sha256," \
  |  |  |  |  |  |   29|      2|	"sntrup761x25519-sha512," \
  |  |  |  |  |  |   30|      2|	"sntrup761x25519-sha512@openssh.com," \
  |  |  |  |  |  |   31|      2|	"curve25519-sha256," \
  |  |  |  |  |  |   32|      2|	"curve25519-sha256@libssh.org," \
  |  |  |  |  |  |   33|      2|	"ecdh-sha2-nistp256," \
  |  |  |  |  |  |   34|      2|	"ecdh-sha2-nistp384," \
  |  |  |  |  |  |   35|      2|	"ecdh-sha2-nistp521" \
  |  |  |  |  ------------------
  |  |  |  |   38|      2|	"diffie-hellman-group-exchange-sha256," \
  |  |  |  |   39|      2|	"diffie-hellman-group16-sha512," \
  |  |  |  |   40|      2|	"diffie-hellman-group18-sha512," \
  |  |  |  |   41|      2|	"diffie-hellman-group14-sha256"
  |  |  ------------------
  |  |  104|      2|	KEX_DEFAULT_PK_ALG, \
  |  |  ------------------
  |  |  |  |   44|      2|	"ssh-ed25519-cert-v01@openssh.com," \
  |  |  |  |   45|      2|	"ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |  |  |   46|      2|	"ecdsa-sha2-nistp384-cert-v01@openssh.com," \
  |  |  |  |   47|      2|	"ecdsa-sha2-nistp521-cert-v01@openssh.com," \
  |  |  |  |   48|      2|	"sk-ssh-ed25519-cert-v01@openssh.com," \
  |  |  |  |   49|      2|	"sk-ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |  |  |   50|      2|	"webauthn-sk-ecdsa-sha2-nistp256-cert-v01@openssh.com," \
  |  |  |  |   51|      2|	"rsa-sha2-512-cert-v01@openssh.com," \
  |  |  |  |   52|      2|	"rsa-sha2-256-cert-v01@openssh.com," \
  |  |  |  |   53|      2|	"ssh-mldsa44-ed25519-cert," \
  |  |  |  |   54|      2|	"ssh-ed25519," \
  |  |  |  |   55|      2|	"ecdsa-sha2-nistp256," \
  |  |  |  |   56|      2|	"ecdsa-sha2-nistp384," \
  |  |  |  |   57|      2|	"ecdsa-sha2-nistp521," \
  |  |  |  |   58|      2|	"sk-ssh-ed25519@openssh.com," \
  |  |  |  |   59|      2|	"sk-ecdsa-sha2-nistp256@openssh.com," \
  |  |  |  |   60|      2|	"webauthn-sk-ecdsa-sha2-nistp256@openssh.com," \
  |  |  |  |   61|      2|	"rsa-sha2-512," \
  |  |  |  |   62|      2|	"rsa-sha2-256," \
  |  |  |  |   63|      2|	"ssh-mldsa44-ed25519"
  |  |  ------------------
  |  |  105|      2|	KEX_CLIENT_ENCRYPT, \
  |  |  ------------------
  |  |  |  |   70|      2|#define KEX_CLIENT_ENCRYPT KEX_SERVER_ENCRYPT
  |  |  |  |  ------------------
  |  |  |  |  |  |   66|      2|	"chacha20-poly1305@openssh.com," \
  |  |  |  |  |  |   67|      2|	"aes128-gcm@openssh.com,aes256-gcm@openssh.com," \
  |  |  |  |  |  |   68|      2|	"aes128-ctr,aes192-ctr,aes256-ctr"
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  106|      2|	KEX_CLIENT_ENCRYPT, \
  |  |  ------------------
  |  |  |  |   70|      2|#define KEX_CLIENT_ENCRYPT KEX_SERVER_ENCRYPT
  |  |  |  |  ------------------
  |  |  |  |  |  |   66|      2|	"chacha20-poly1305@openssh.com," \
  |  |  |  |  |  |   67|      2|	"aes128-gcm@openssh.com,aes256-gcm@openssh.com," \
  |  |  |  |  |  |   68|      2|	"aes128-ctr,aes192-ctr,aes256-ctr"
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      2|	KEX_CLIENT_MAC, \
  |  |  ------------------
  |  |  |  |   84|      2|#define KEX_CLIENT_MAC KEX_SERVER_MAC
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|      2|	"umac-64-etm@openssh.com," \
  |  |  |  |  |  |   74|      2|	"umac-128-etm@openssh.com," \
  |  |  |  |  |  |   75|      2|	"hmac-sha2-256-etm@openssh.com," \
  |  |  |  |  |  |   76|      2|	"hmac-sha2-512-etm@openssh.com," \
  |  |  |  |  |  |   77|      2|	"hmac-sha1-etm@openssh.com," \
  |  |  |  |  |  |   78|      2|	"umac-64@openssh.com," \
  |  |  |  |  |  |   79|      2|	"umac-128@openssh.com," \
  |  |  |  |  |  |   80|      2|	"hmac-sha2-256," \
  |  |  |  |  |  |   81|      2|	"hmac-sha2-512," \
  |  |  |  |  |  |   82|      2|	"hmac-sha1"
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|      2|	KEX_CLIENT_MAC, \
  |  |  ------------------
  |  |  |  |   84|      2|#define KEX_CLIENT_MAC KEX_SERVER_MAC
  |  |  |  |  ------------------
  |  |  |  |  |  |   73|      2|	"umac-64-etm@openssh.com," \
  |  |  |  |  |  |   74|      2|	"umac-128-etm@openssh.com," \
  |  |  |  |  |  |   75|      2|	"hmac-sha2-256-etm@openssh.com," \
  |  |  |  |  |  |   76|      2|	"hmac-sha2-512-etm@openssh.com," \
  |  |  |  |  |  |   77|      2|	"hmac-sha1-etm@openssh.com," \
  |  |  |  |  |  |   78|      2|	"umac-64@openssh.com," \
  |  |  |  |  |  |   79|      2|	"umac-128@openssh.com," \
  |  |  |  |  |  |   80|      2|	"hmac-sha2-256," \
  |  |  |  |  |  |   81|      2|	"hmac-sha2-512," \
  |  |  |  |  |  |   82|      2|	"hmac-sha1"
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  109|      2|	KEX_DEFAULT_COMP, \
  |  |  ------------------
  |  |  |  |   99|      2|#define	KEX_DEFAULT_COMP	"none,zlib@openssh.com"
  |  |  ------------------
  |  |  110|      2|	KEX_DEFAULT_COMP, \
  |  |  ------------------
  |  |  |  |   99|      2|#define	KEX_DEFAULT_COMP	"none,zlib@openssh.com"
  |  |  ------------------
  |  |  111|      2|	KEX_DEFAULT_LANG, \
  |  |  ------------------
  |  |  |  |  100|      2|#define	KEX_DEFAULT_LANG	""
  |  |  ------------------
  |  |  112|      2|	KEX_DEFAULT_LANG
  |  |  ------------------
  |  |  |  |  100|      2|#define	KEX_DEFAULT_LANG	""
  |  |  ------------------
  ------------------
   90|      2|	char *populated[PROPOSAL_MAX];
   91|      2|	struct ssh *ssh;
   92|      2|	char **proposal;
   93|      2|	static int called;
   94|      2|	int r;
   95|       |
   96|      2|	if (!called) {
  ------------------
  |  Branch (96:6): [True: 1, False: 1]
  ------------------
   97|      1|		seed_rng();
   98|      1|		called = 1;
   99|      1|	}
  100|       |
  101|      2|	if ((ssh = ssh_packet_set_connection(NULL, -1, -1)) == NULL)
  ------------------
  |  Branch (101:6): [True: 0, False: 2]
  ------------------
  102|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  103|      2|	if (is_server)
  ------------------
  |  Branch (103:6): [True: 1, False: 1]
  ------------------
  104|      1|		ssh_packet_set_server(ssh);
  105|       |
  106|       |	/* Initialize key exchange */
  107|      2|	proposal = kex_params ? kex_params->proposal : myproposal;
  ------------------
  |  Branch (107:13): [True: 2, False: 0]
  ------------------
  108|      2|	kex_proposal_populate_entries(ssh, populated,
  109|      2|	    proposal[PROPOSAL_KEX_ALGS],
  110|      2|	    proposal[PROPOSAL_ENC_ALGS_CTOS],
  111|      2|	    proposal[PROPOSAL_MAC_ALGS_CTOS],
  112|      2|	    proposal[PROPOSAL_COMP_ALGS_CTOS],
  113|      2|	    proposal[PROPOSAL_SERVER_HOST_KEY_ALGS]);
  114|      2|	r = kex_ready(ssh, populated);
  115|      2|	kex_proposal_free_entries(populated);
  116|      2|	if (r != 0) {
  ------------------
  |  Branch (116:6): [True: 0, False: 2]
  ------------------
  117|      0|		ssh_free(ssh);
  118|      0|		return r;
  119|      0|	}
  120|       |
  121|      2|	ssh->kex->server = is_server;
  122|      2|	if (is_server) {
  ------------------
  |  Branch (122:6): [True: 1, False: 1]
  ------------------
  123|      1|#ifdef WITH_OPENSSL
  124|      1|		ssh->kex->kex[KEX_DH_GRP1_SHA1] = kex_gen_server;
  125|      1|		ssh->kex->kex[KEX_DH_GRP14_SHA1] = kex_gen_server;
  126|      1|		ssh->kex->kex[KEX_DH_GRP14_SHA256] = kex_gen_server;
  127|      1|		ssh->kex->kex[KEX_DH_GRP16_SHA512] = kex_gen_server;
  128|      1|		ssh->kex->kex[KEX_DH_GRP18_SHA512] = kex_gen_server;
  129|      1|		ssh->kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
  130|      1|		ssh->kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
  131|      1|		ssh->kex->kex[KEX_ECDH_SHA2] = kex_gen_server;
  132|      1|#endif /* WITH_OPENSSL */
  133|      1|		ssh->kex->kex[KEX_C25519_SHA256] = kex_gen_server;
  134|      1|		ssh->kex->kex[KEX_KEM_SNTRUP761X25519_SHA512] = kex_gen_server;
  135|      1|		ssh->kex->kex[KEX_KEM_MLKEM768X25519_SHA256] = kex_gen_server;
  136|      1|		ssh->kex->kex[KEX_KEM_MLKEM768ECDH_SHA256] = kex_gen_server;
  137|      1|		ssh->kex->load_host_public_key=&_ssh_host_public_key;
  138|      1|		ssh->kex->load_host_private_key=&_ssh_host_private_key;
  139|      1|		ssh->kex->sign=&_ssh_host_key_sign;
  140|      1|	} else {
  141|      1|#ifdef WITH_OPENSSL
  142|      1|		ssh->kex->kex[KEX_DH_GRP1_SHA1] = kex_gen_client;
  143|      1|		ssh->kex->kex[KEX_DH_GRP14_SHA1] = kex_gen_client;
  144|      1|		ssh->kex->kex[KEX_DH_GRP14_SHA256] = kex_gen_client;
  145|      1|		ssh->kex->kex[KEX_DH_GRP16_SHA512] = kex_gen_client;
  146|      1|		ssh->kex->kex[KEX_DH_GRP18_SHA512] = kex_gen_client;
  147|      1|		ssh->kex->kex[KEX_DH_GEX_SHA1] = kexgex_client;
  148|      1|		ssh->kex->kex[KEX_DH_GEX_SHA256] = kexgex_client;
  149|      1|		ssh->kex->kex[KEX_ECDH_SHA2] = kex_gen_client;
  150|      1|#endif /* WITH_OPENSSL */
  151|      1|		ssh->kex->kex[KEX_C25519_SHA256] = kex_gen_client;
  152|      1|		ssh->kex->kex[KEX_KEM_SNTRUP761X25519_SHA512] = kex_gen_client;
  153|      1|		ssh->kex->kex[KEX_KEM_MLKEM768X25519_SHA256] = kex_gen_client;
  154|      1|		ssh->kex->kex[KEX_KEM_MLKEM768ECDH_SHA256] = kex_gen_client;
  155|      1|		ssh->kex->verify_host_key =&_ssh_verify_host_key;
  156|      1|	}
  157|      2|	*sshp = ssh;
  158|      2|	return 0;
  159|      2|}
ssh_add_hostkey:
  202|      2|{
  203|      2|	struct sshkey *pubkey = NULL;
  204|      2|	struct key_entry *k = NULL, *k_prv = NULL;
  205|      2|	int r;
  206|       |
  207|      2|	if (ssh->kex->server) {
  ------------------
  |  Branch (207:6): [True: 1, False: 1]
  ------------------
  208|      1|		if ((r = sshkey_from_private(key, &pubkey)) != 0)
  ------------------
  |  Branch (208:7): [True: 0, False: 1]
  ------------------
  209|      0|			return r;
  210|      1|		if ((k = malloc(sizeof(*k))) == NULL ||
  ------------------
  |  Branch (210:7): [True: 0, False: 1]
  ------------------
  211|      1|		    (k_prv = malloc(sizeof(*k_prv))) == NULL) {
  ------------------
  |  Branch (211:7): [True: 0, False: 1]
  ------------------
  212|      0|			free(k);
  213|      0|			sshkey_free(pubkey);
  214|      0|			return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  215|      0|		}
  216|      1|		k_prv->key = key;
  217|      1|		TAILQ_INSERT_TAIL(&ssh->private_keys, k_prv, next);
  ------------------
  |  |  572|      1|#define TAILQ_INSERT_TAIL(head, elm, field) do {			\
  |  |  573|      1|	(elm)->field.tqe_next = NULL;					\
  |  |  574|      1|	(elm)->field.tqe_prev = (head)->tqh_last;			\
  |  |  575|      1|	*(head)->tqh_last = (elm);					\
  |  |  576|      1|	(head)->tqh_last = &(elm)->field.tqe_next;			\
  |  |  577|      1|} while (0)
  |  |  ------------------
  |  |  |  Branch (577:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  218|       |
  219|       |		/* add the public key, too */
  220|      1|		k->key = pubkey;
  221|      1|		TAILQ_INSERT_TAIL(&ssh->public_keys, k, next);
  ------------------
  |  |  572|      1|#define TAILQ_INSERT_TAIL(head, elm, field) do {			\
  |  |  573|      1|	(elm)->field.tqe_next = NULL;					\
  |  |  574|      1|	(elm)->field.tqe_prev = (head)->tqh_last;			\
  |  |  575|      1|	*(head)->tqh_last = (elm);					\
  |  |  576|      1|	(head)->tqh_last = &(elm)->field.tqe_next;			\
  |  |  577|      1|} while (0)
  |  |  ------------------
  |  |  |  Branch (577:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  222|      1|		r = 0;
  223|      1|	} else {
  224|      1|		if ((k = malloc(sizeof(*k))) == NULL)
  ------------------
  |  Branch (224:7): [True: 0, False: 1]
  ------------------
  225|      0|			return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  226|      1|		k->key = key;
  227|      1|		TAILQ_INSERT_TAIL(&ssh->public_keys, k, next);
  ------------------
  |  |  572|      1|#define TAILQ_INSERT_TAIL(head, elm, field) do {			\
  |  |  573|      1|	(elm)->field.tqe_next = NULL;					\
  |  |  574|      1|	(elm)->field.tqe_prev = (head)->tqh_last;			\
  |  |  575|      1|	*(head)->tqh_last = (elm);					\
  |  |  576|      1|	(head)->tqh_last = &(elm)->field.tqe_next;			\
  |  |  577|      1|} while (0)
  |  |  ------------------
  |  |  |  Branch (577:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  228|      1|		r = 0;
  229|      1|	}
  230|       |
  231|      2|	return r;
  232|      2|}
ssh_input_append:
  248|    519|{
  249|    519|	return sshbuf_put(ssh_packet_get_input(ssh), data, len);
  250|    519|}
ssh_packet_next:
  254|    521|{
  255|    521|	int r;
  256|    521|	uint32_t seqnr;
  257|    521|	u_char type;
  258|       |
  259|       |	/*
  260|       |	 * Try to read a packet. Return SSH_MSG_NONE if no packet or not
  261|       |	 * enough data.
  262|       |	 */
  263|    521|	*typep = SSH_MSG_NONE;
  ------------------
  |  |   61|    521|#define SSH_MSG_NONE					0
  ------------------
  264|    521|	if (sshbuf_len(ssh->kex->client_version) == 0 ||
  ------------------
  |  Branch (264:6): [True: 3, False: 518]
  ------------------
  265|    518|	    sshbuf_len(ssh->kex->server_version) == 0)
  ------------------
  |  Branch (265:6): [True: 0, False: 518]
  ------------------
  266|      3|		return _ssh_exchange_banner(ssh);
  267|       |	/*
  268|       |	 * If we enough data and a dispatch function then
  269|       |	 * call the function and get the next packet.
  270|       |	 * Otherwise return the packet type to the caller so it
  271|       |	 * can decide how to go on.
  272|       |	 *
  273|       |	 * We will only call the dispatch function for:
  274|       |	 *     20-29    Algorithm negotiation
  275|       |	 *     30-49    Key exchange method specific (numbers can be reused for
  276|       |	 *              different authentication methods)
  277|       |	 */
  278|    524|	for (;;) {
  279|    524|		if ((r = ssh_packet_read_poll2(ssh, &type, &seqnr)) != 0)
  ------------------
  |  Branch (279:7): [True: 0, False: 524]
  ------------------
  280|      0|			return r;
  281|    524|		if (type > 0 && type < DISPATCH_MAX &&
  ------------------
  |  |   30|    532|#define DISPATCH_MAX	255
  ------------------
  |  Branch (281:7): [True: 8, False: 516]
  |  Branch (281:19): [True: 8, False: 0]
  ------------------
  282|      8|		    type >= SSH2_MSG_KEXINIT && type <= SSH2_MSG_TRANSPORT_MAX &&
  ------------------
  |  |   93|    532|#define SSH2_MSG_KEXINIT				20
  ------------------
              		    type >= SSH2_MSG_KEXINIT && type <= SSH2_MSG_TRANSPORT_MAX &&
  ------------------
  |  |   66|    530|#define SSH2_MSG_TRANSPORT_MAX				49
  ------------------
  |  Branch (282:7): [True: 6, False: 2]
  |  Branch (282:35): [True: 6, False: 0]
  ------------------
  283|      6|		    ssh->dispatch[type] != NULL) {
  ------------------
  |  Branch (283:7): [True: 6, False: 0]
  ------------------
  284|      6|			if ((r = (*ssh->dispatch[type])(type, seqnr, ssh)) != 0)
  ------------------
  |  Branch (284:8): [True: 0, False: 6]
  ------------------
  285|      0|				return r;
  286|    518|		} else {
  287|    518|			*typep = type;
  288|    518|			return 0;
  289|    518|		}
  290|    524|	}
  291|    518|}
ssh_packet_put:
  301|    513|{
  302|    513|	int r;
  303|       |
  304|    513|	if ((r = sshpkt_start(ssh, type)) != 0 ||
  ------------------
  |  Branch (304:6): [True: 0, False: 513]
  ------------------
  305|    513|	    (r = sshpkt_put(ssh, data, len)) != 0 ||
  ------------------
  |  Branch (305:6): [True: 0, False: 513]
  ------------------
  306|    513|	    (r = sshpkt_send(ssh)) != 0)
  ------------------
  |  Branch (306:6): [True: 0, False: 513]
  ------------------
  307|      0|		return r;
  308|    513|	return 0;
  309|    513|}
ssh_output_ptr:
  313|    521|{
  314|    521|	struct sshbuf *output = ssh_packet_get_output(ssh);
  315|       |
  316|    521|	*len = sshbuf_len(output);
  317|    521|	return sshbuf_ptr(output);
  318|    521|}
ssh_output_consume:
  322|    519|{
  323|    519|	return sshbuf_consume(ssh_packet_get_output(ssh), len);
  324|    519|}
_ssh_read_banner:
  341|      3|{
  342|      3|	struct sshbuf *input = ssh_packet_get_input(ssh);
  343|      3|	const char *mismatch = "Protocol mismatch.\r\n";
  344|      3|	const u_char *s = sshbuf_ptr(input);
  345|      3|	u_char c;
  346|      3|	char *cp = NULL, *remote_version = NULL;
  347|      3|	int r = 0, remote_major, remote_minor, expect_nl;
  348|      3|	size_t n, j;
  349|       |
  350|      3|	for (j = n = 0;;) {
  351|      3|		sshbuf_reset(banner);
  352|      3|		expect_nl = 0;
  353|     45|		for (;;) {
  354|     45|			if (j >= sshbuf_len(input))
  ------------------
  |  Branch (354:8): [True: 1, False: 44]
  ------------------
  355|      1|				return 0; /* insufficient data in input buf */
  356|     44|			c = s[j++];
  357|     44|			if (c == '\r') {
  ------------------
  |  Branch (357:8): [True: 2, False: 42]
  ------------------
  358|      2|				expect_nl = 1;
  359|      2|				continue;
  360|      2|			}
  361|     42|			if (c == '\n')
  ------------------
  |  Branch (361:8): [True: 2, False: 40]
  ------------------
  362|      2|				break;
  363|     40|			if (expect_nl)
  ------------------
  |  Branch (363:8): [True: 0, False: 40]
  ------------------
  364|      0|				goto bad;
  365|     40|			if ((r = sshbuf_put_u8(banner, c)) != 0)
  ------------------
  |  Branch (365:8): [True: 0, False: 40]
  ------------------
  366|      0|				return r;
  367|     40|			if (sshbuf_len(banner) > SSH_MAX_BANNER_LEN)
  ------------------
  |  |   92|     40|#define SSH_MAX_BANNER_LEN		8192
  ------------------
  |  Branch (367:8): [True: 0, False: 40]
  ------------------
  368|      0|				goto bad;
  369|     40|		}
  370|      2|		if (sshbuf_len(banner) >= 4 &&
  ------------------
  |  Branch (370:7): [True: 2, False: 0]
  ------------------
  371|      2|		    memcmp(sshbuf_ptr(banner), "SSH-", 4) == 0)
  ------------------
  |  Branch (371:7): [True: 2, False: 0]
  ------------------
  372|      2|			break;
  373|      0|		debug_f("%.*s", (int)sshbuf_len(banner),
  ------------------
  |  |  122|      0|#define debug_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  374|      0|		    sshbuf_ptr(banner));
  375|       |		/* Accept lines before banner only on client */
  376|      0|		if (ssh->kex->server || ++n > SSH_MAX_PRE_BANNER_LINES) {
  ------------------
  |  |   93|      0|#define SSH_MAX_PRE_BANNER_LINES	1024
  ------------------
  |  Branch (376:7): [True: 0, False: 0]
  |  Branch (376:27): [True: 0, False: 0]
  ------------------
  377|      0|  bad:
  378|      0|			if ((r = sshbuf_put(ssh_packet_get_output(ssh),
  ------------------
  |  Branch (378:8): [True: 0, False: 0]
  ------------------
  379|      0|			    mismatch, strlen(mismatch))) != 0)
  380|      0|				return r;
  381|      0|			return SSH_ERR_NO_PROTOCOL_VERSION;
  ------------------
  |  |   62|      0|#define SSH_ERR_NO_PROTOCOL_VERSION		-38
  ------------------
  382|      0|		}
  383|      0|	}
  384|      2|	if ((r = sshbuf_consume(input, j)) != 0)
  ------------------
  |  Branch (384:6): [True: 0, False: 2]
  ------------------
  385|      0|		return r;
  386|       |
  387|       |	/* XXX remote version must be the same size as banner for sscanf */
  388|      2|	if ((cp = sshbuf_dup_string(banner)) == NULL ||
  ------------------
  |  Branch (388:6): [True: 0, False: 2]
  ------------------
  389|      2|	    (remote_version = calloc(1, sshbuf_len(banner))) == NULL) {
  ------------------
  |  Branch (389:6): [True: 0, False: 2]
  ------------------
  390|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  391|      0|		goto out;
  392|      0|	}
  393|       |
  394|       |	/*
  395|       |	 * Check that the versions match.  In future this might accept
  396|       |	 * several versions and set appropriate flags to handle them.
  397|       |	 */
  398|      2|	if (sscanf(cp, "SSH-%d.%d-%[^\n]\n",
  ------------------
  |  Branch (398:6): [True: 0, False: 2]
  ------------------
  399|      2|	    &remote_major, &remote_minor, remote_version) != 3) {
  400|      0|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  401|      0|		goto out;
  402|      0|	}
  403|      2|	debug("Remote protocol version %d.%d, remote software version %.100s",
  ------------------
  |  |  111|      2|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  404|      2|	    remote_major, remote_minor, remote_version);
  405|       |
  406|      2|	compat_banner(ssh, remote_version);
  407|      2|	if  (remote_major == 1 && remote_minor == 99) {
  ------------------
  |  Branch (407:7): [True: 0, False: 2]
  |  Branch (407:28): [True: 0, False: 0]
  ------------------
  408|      0|		remote_major = 2;
  409|      0|		remote_minor = 0;
  410|      0|	}
  411|      2|	if (remote_major != 2)
  ------------------
  |  Branch (411:6): [True: 0, False: 2]
  ------------------
  412|      0|		r = SSH_ERR_PROTOCOL_MISMATCH;
  ------------------
  |  |   61|      0|#define SSH_ERR_PROTOCOL_MISMATCH		-37
  ------------------
  413|       |
  414|      2|	debug("Remote version string %.100s", cp);
  ------------------
  |  |  111|      2|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  415|      2| out:
  416|      2|	free(cp);
  417|      2|	free(remote_version);
  418|      2|	return r;
  419|      2|}
_ssh_send_banner:
  424|      2|{
  425|      2|	char *cp;
  426|      2|	int r;
  427|       |
  428|      2|	if ((r = sshbuf_putf(banner, "SSH-2.0-%.100s\r\n", SSH_VERSION)) != 0)
  ------------------
  |  |    3|      2|#define SSH_VERSION	"OpenSSH_10.6"
  ------------------
  |  Branch (428:6): [True: 0, False: 2]
  ------------------
  429|      0|		return r;
  430|      2|	if ((r = sshbuf_putb(ssh_packet_get_output(ssh), banner)) != 0)
  ------------------
  |  Branch (430:6): [True: 0, False: 2]
  ------------------
  431|      0|		return r;
  432|       |	/* Remove trailing \r\n */
  433|      2|	if ((r = sshbuf_consume_end(banner, 2)) != 0)
  ------------------
  |  Branch (433:6): [True: 0, False: 2]
  ------------------
  434|      0|		return r;
  435|      2|	if ((cp = sshbuf_dup_string(banner)) == NULL)
  ------------------
  |  Branch (435:6): [True: 0, False: 2]
  ------------------
  436|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  437|      2|	debug("Local version string %.100s", cp);
  ------------------
  |  |  111|      2|#define debug(...)		sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, NULL, __VA_ARGS__)
  ------------------
  438|      2|	free(cp);
  439|      2|	return 0;
  440|      2|}
_ssh_exchange_banner:
  444|      3|{
  445|      3|	struct kex *kex = ssh->kex;
  446|      3|	int r;
  447|       |
  448|       |	/*
  449|       |	 * if _ssh_read_banner() cannot parse a full version string
  450|       |	 * it will return NULL and we end up calling it again.
  451|       |	 */
  452|       |
  453|      3|	r = 0;
  454|      3|	if (kex->server) {
  ------------------
  |  Branch (454:6): [True: 2, False: 1]
  ------------------
  455|      2|		if (sshbuf_len(ssh->kex->server_version) == 0)
  ------------------
  |  Branch (455:7): [True: 1, False: 1]
  ------------------
  456|      1|			r = _ssh_send_banner(ssh, ssh->kex->server_version);
  457|      2|		if (r == 0 &&
  ------------------
  |  Branch (457:7): [True: 2, False: 0]
  ------------------
  458|      2|		    sshbuf_len(ssh->kex->server_version) != 0 &&
  ------------------
  |  Branch (458:7): [True: 2, False: 0]
  ------------------
  459|      2|		    sshbuf_len(ssh->kex->client_version) == 0)
  ------------------
  |  Branch (459:7): [True: 2, False: 0]
  ------------------
  460|      2|			r = _ssh_read_banner(ssh, ssh->kex->client_version);
  461|      2|	} else {
  462|      1|		if (sshbuf_len(ssh->kex->server_version) == 0)
  ------------------
  |  Branch (462:7): [True: 1, False: 0]
  ------------------
  463|      1|			r = _ssh_read_banner(ssh, ssh->kex->server_version);
  464|      1|		if (r == 0 &&
  ------------------
  |  Branch (464:7): [True: 1, False: 0]
  ------------------
  465|      1|		    sshbuf_len(ssh->kex->server_version) != 0 &&
  ------------------
  |  Branch (465:7): [True: 1, False: 0]
  ------------------
  466|      1|		    sshbuf_len(ssh->kex->client_version) == 0)
  ------------------
  |  Branch (466:7): [True: 1, False: 0]
  ------------------
  467|      1|			r = _ssh_send_banner(ssh, ssh->kex->client_version);
  468|      1|	}
  469|      3|	if (r != 0)
  ------------------
  |  Branch (469:6): [True: 0, False: 3]
  ------------------
  470|      0|		return r;
  471|       |	/* start initial kex as soon as we have exchanged the banners */
  472|      3|	if (sshbuf_len(ssh->kex->server_version) != 0 &&
  ------------------
  |  Branch (472:6): [True: 3, False: 0]
  ------------------
  473|      3|	    sshbuf_len(ssh->kex->client_version) != 0) {
  ------------------
  |  Branch (473:6): [True: 2, False: 1]
  ------------------
  474|      2|		if ((r = _ssh_order_hostkeyalgs(ssh)) != 0 ||
  ------------------
  |  Branch (474:7): [True: 0, False: 2]
  ------------------
  475|      2|		    (r = kex_send_kexinit(ssh)) != 0)
  ------------------
  |  Branch (475:7): [True: 0, False: 2]
  ------------------
  476|      0|			return r;
  477|      2|	}
  478|      3|	return 0;
  479|      3|}
_ssh_host_public_key:
  483|      1|{
  484|      1|	struct key_entry *k;
  485|       |
  486|      1|	debug3_f("need %d", type);
  ------------------
  |  |  120|      1|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  487|      1|	TAILQ_FOREACH(k, &ssh->public_keys, next) {
  ------------------
  |  |  532|      1|	for((var) = TAILQ_FIRST(head);					\
  |  |  ------------------
  |  |  |  |  520|      1|#define	TAILQ_FIRST(head)		((head)->tqh_first)
  |  |  ------------------
  |  |  533|      1|	    (var) != TAILQ_END(head);					\
  |  |  ------------------
  |  |  |  |  521|      1|#define	TAILQ_END(head)			NULL
  |  |  ------------------
  |  |  |  Branch (533:6): [True: 1, False: 0]
  |  |  ------------------
  |  |  534|      1|	    (var) = TAILQ_NEXT(var, field))
  |  |  ------------------
  |  |  |  |  522|      0|#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
  |  |  ------------------
  ------------------
  488|      1|		debug3_f("check %s", sshkey_type(k->key));
  ------------------
  |  |  120|      1|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  489|      1|		if (k->key->type == type &&
  ------------------
  |  Branch (489:7): [True: 1, False: 0]
  ------------------
  490|      1|		    (type != KEY_ECDSA || k->key->ecdsa_nid == nid))
  ------------------
  |  Branch (490:8): [True: 1, False: 0]
  |  Branch (490:29): [True: 0, False: 0]
  ------------------
  491|      1|			return (k->key);
  492|      1|	}
  493|      0|	return (NULL);
  494|      1|}
_ssh_host_private_key:
  498|      1|{
  499|      1|	struct key_entry *k;
  500|       |
  501|      1|	debug3_f("need %d", type);
  ------------------
  |  |  120|      1|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  502|      1|	TAILQ_FOREACH(k, &ssh->private_keys, next) {
  ------------------
  |  |  532|      1|	for((var) = TAILQ_FIRST(head);					\
  |  |  ------------------
  |  |  |  |  520|      1|#define	TAILQ_FIRST(head)		((head)->tqh_first)
  |  |  ------------------
  |  |  533|      1|	    (var) != TAILQ_END(head);					\
  |  |  ------------------
  |  |  |  |  521|      1|#define	TAILQ_END(head)			NULL
  |  |  ------------------
  |  |  |  Branch (533:6): [True: 1, False: 0]
  |  |  ------------------
  |  |  534|      1|	    (var) = TAILQ_NEXT(var, field))
  |  |  ------------------
  |  |  |  |  522|      0|#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
  |  |  ------------------
  ------------------
  503|      1|		debug3_f("check %s", sshkey_type(k->key));
  ------------------
  |  |  120|      1|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  504|      1|		if (k->key->type == type &&
  ------------------
  |  Branch (504:7): [True: 1, False: 0]
  ------------------
  505|      1|		    (type != KEY_ECDSA || k->key->ecdsa_nid == nid))
  ------------------
  |  Branch (505:8): [True: 1, False: 0]
  |  Branch (505:29): [True: 0, False: 0]
  ------------------
  506|      1|			return (k->key);
  507|      1|	}
  508|      0|	return (NULL);
  509|      1|}
_ssh_verify_host_key:
  513|      1|{
  514|      1|	struct key_entry *k;
  515|       |
  516|      1|	debug3_f("need %s", sshkey_type(hostkey));
  ------------------
  |  |  120|      1|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  517|      1|	TAILQ_FOREACH(k, &ssh->public_keys, next) {
  ------------------
  |  |  532|      1|	for((var) = TAILQ_FIRST(head);					\
  |  |  ------------------
  |  |  |  |  520|      1|#define	TAILQ_FIRST(head)		((head)->tqh_first)
  |  |  ------------------
  |  |  533|      1|	    (var) != TAILQ_END(head);					\
  |  |  ------------------
  |  |  |  |  521|      1|#define	TAILQ_END(head)			NULL
  |  |  ------------------
  |  |  |  Branch (533:6): [True: 1, False: 0]
  |  |  ------------------
  |  |  534|      1|	    (var) = TAILQ_NEXT(var, field))
  |  |  ------------------
  |  |  |  |  522|      0|#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
  |  |  ------------------
  ------------------
  518|      1|		debug3_f("check %s", sshkey_type(k->key));
  ------------------
  |  |  120|      1|#define debug3_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
  ------------------
  519|      1|		if (sshkey_equal_public(hostkey, k->key))
  ------------------
  |  Branch (519:7): [True: 1, False: 0]
  ------------------
  520|      1|			return (0);	/* ok */
  521|      1|	}
  522|      0|	return (-1);	/* failed */
  523|      1|}
_ssh_order_hostkeyalgs:
  528|      2|{
  529|      2|	struct key_entry *k;
  530|      2|	char *orig, *avail, *oavail = NULL, *alg, *replace = NULL;
  531|      2|	char **proposal;
  532|      2|	size_t maxlen;
  533|      2|	int ktype, nid, r;
  534|       |
  535|       |	/* XXX we de-serialize ssh->kex->my, modify it, and change it */
  536|      2|	if ((r = kex_buf2prop(ssh->kex->my, NULL, &proposal)) != 0)
  ------------------
  |  Branch (536:6): [True: 0, False: 2]
  ------------------
  537|      0|		return r;
  538|      2|	orig = proposal[PROPOSAL_SERVER_HOST_KEY_ALGS];
  539|      2|	if ((oavail = avail = strdup(orig)) == NULL) {
  ------------------
  |  Branch (539:6): [True: 0, False: 2]
  ------------------
  540|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  541|      0|		goto out;
  542|      0|	}
  543|      2|	maxlen = strlen(avail) + 1;
  544|      2|	if ((replace = calloc(1, maxlen)) == NULL) {
  ------------------
  |  Branch (544:6): [True: 0, False: 2]
  ------------------
  545|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  546|      0|		goto out;
  547|      0|	}
  548|      2|	*replace = '\0';
  549|      4|	while ((alg = strsep(&avail, ",")) && *alg != '\0') {
  ------------------
  |  Branch (549:9): [True: 2, False: 2]
  |  Branch (549:40): [True: 2, False: 0]
  ------------------
  550|      2|		if ((ktype = sshkey_type_from_name(alg)) == KEY_UNSPEC)
  ------------------
  |  Branch (550:7): [True: 0, False: 2]
  ------------------
  551|      0|			continue;
  552|      2|		nid = sshkey_ecdsa_nid_from_name(alg);
  553|      2|		TAILQ_FOREACH(k, &ssh->public_keys, next) {
  ------------------
  |  |  532|      2|	for((var) = TAILQ_FIRST(head);					\
  |  |  ------------------
  |  |  |  |  520|      2|#define	TAILQ_FIRST(head)		((head)->tqh_first)
  |  |  ------------------
  |  |  533|      2|	    (var) != TAILQ_END(head);					\
  |  |  ------------------
  |  |  |  |  521|      2|#define	TAILQ_END(head)			NULL
  |  |  ------------------
  |  |  |  Branch (533:6): [True: 2, False: 0]
  |  |  ------------------
  |  |  534|      2|	    (var) = TAILQ_NEXT(var, field))
  |  |  ------------------
  |  |  |  |  522|      0|#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
  |  |  ------------------
  ------------------
  554|      2|			if (k->key->type != ktype &&
  ------------------
  |  Branch (554:8): [True: 0, False: 2]
  ------------------
  555|      0|			    (!sshkey_is_cert(k->key) ||
  ------------------
  |  Branch (555:9): [True: 0, False: 0]
  ------------------
  556|      0|			    k->key->type != sshkey_type_plain(ktype)))
  ------------------
  |  Branch (556:8): [True: 0, False: 0]
  ------------------
  557|      0|				continue;
  558|      2|			if (sshkey_type_plain(k->key->type) == KEY_ECDSA &&
  ------------------
  |  Branch (558:8): [True: 0, False: 2]
  ------------------
  559|      0|			    k->key->ecdsa_nid != nid)
  ------------------
  |  Branch (559:8): [True: 0, False: 0]
  ------------------
  560|      0|				continue;
  561|       |			/* Candidate */
  562|      2|			if (*replace != '\0')
  ------------------
  |  Branch (562:8): [True: 0, False: 2]
  ------------------
  563|      0|				strlcat(replace, ",", maxlen);
  564|      2|			strlcat(replace, alg, maxlen);
  565|      2|			break;
  566|      2|		}
  567|      2|	}
  568|      2|	if (*replace != '\0') {
  ------------------
  |  Branch (568:6): [True: 2, False: 0]
  ------------------
  569|      2|		debug2_f("orig/%d    %s", ssh->kex->server, orig);
  ------------------
  |  |  121|      2|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  570|      2|		debug2_f("replace/%d %s", ssh->kex->server, replace);
  ------------------
  |  |  121|      2|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  571|      2|		free(orig);
  572|      2|		proposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = replace;
  573|      2|		replace = NULL;	/* owned by proposal */
  574|      2|		r = kex_prop2buf(ssh->kex->my, proposal);
  575|      2|	}
  576|      2| out:
  577|      2|	free(oavail);
  578|      2|	free(replace);
  579|      2|	kex_prop_free(proposal);
  580|      2|	return r;
  581|      2|}
_ssh_host_key_sign:
  587|      1|{
  588|      1|	return sshkey_sign(privkey, signature, slen, data, dlen,
  589|      1|	    alg, NULL, NULL, ssh->compat);
  590|      1|}

sshbuf_get_u32:
   60|     14|{
   61|     14|	const u_char *p = sshbuf_ptr(buf);
   62|     14|	int r;
   63|       |
   64|     14|	if ((r = sshbuf_consume(buf, 4)) < 0)
  ------------------
  |  Branch (64:6): [True: 0, False: 14]
  ------------------
   65|      0|		return r;
   66|     14|	if (valp != NULL)
  ------------------
  |  Branch (66:6): [True: 12, False: 2]
  ------------------
   67|     12|		*valp = PEEK_U32(p);
  ------------------
  |  |  351|     12|	(((uint32_t)(((const u_char *)(p))[0]) << 24) | \
  |  |  352|     12|	 ((uint32_t)(((const u_char *)(p))[1]) << 16) | \
  |  |  353|     12|	 ((uint32_t)(((const u_char *)(p))[2]) << 8) | \
  |  |  354|     12|	  (uint32_t)(((const u_char *)(p))[3]))
  ------------------
   68|     14|	return 0;
   69|     14|}
sshbuf_get_u8:
   86|    495|{
   87|    495|	const u_char *p = sshbuf_ptr(buf);
   88|    495|	int r;
   89|       |
   90|    495|	if ((r = sshbuf_consume(buf, 1)) < 0)
  ------------------
  |  Branch (90:6): [True: 2, False: 493]
  ------------------
   91|      2|		return r;
   92|    493|	if (valp != NULL)
  ------------------
  |  Branch (92:6): [True: 459, False: 34]
  ------------------
   93|    459|		*valp = (uint8_t)*p;
   94|    493|	return 0;
   95|    495|}
sshbuf_get_string:
  186|     26|{
  187|     26|	const u_char *val;
  188|     26|	size_t len;
  189|     26|	int r;
  190|       |
  191|     26|	if (valp != NULL)
  ------------------
  |  Branch (191:6): [True: 6, False: 20]
  ------------------
  192|      6|		*valp = NULL;
  193|     26|	if (lenp != NULL)
  ------------------
  |  Branch (193:6): [True: 6, False: 20]
  ------------------
  194|      6|		*lenp = 0;
  195|     26|	if ((r = sshbuf_get_string_direct(buf, &val, &len)) < 0)
  ------------------
  |  Branch (195:6): [True: 0, False: 26]
  ------------------
  196|      0|		return r;
  197|     26|	if (valp != NULL) {
  ------------------
  |  Branch (197:6): [True: 6, False: 20]
  ------------------
  198|      6|		if ((*valp = malloc(len + 1)) == NULL) {
  ------------------
  |  Branch (198:7): [True: 0, False: 6]
  ------------------
  199|      0|			SSHBUF_DBG(("SSH_ERR_ALLOC_FAIL"));
  200|      0|			return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  201|      0|		}
  202|      6|		if (len != 0)
  ------------------
  |  Branch (202:7): [True: 6, False: 0]
  ------------------
  203|      6|			memcpy(*valp, val, len);
  204|      6|		(*valp)[len] = '\0';
  205|      6|	}
  206|     26|	if (lenp != NULL)
  ------------------
  |  Branch (206:6): [True: 6, False: 20]
  ------------------
  207|      6|		*lenp = len;
  208|     26|	return 0;
  209|     26|}
sshbuf_get_string_direct:
  213|  1.17k|{
  214|  1.17k|	size_t len;
  215|  1.17k|	const u_char *p;
  216|  1.17k|	int r;
  217|       |
  218|  1.17k|	if (valp != NULL)
  ------------------
  |  Branch (218:6): [True: 27, False: 1.14k]
  ------------------
  219|     27|		*valp = NULL;
  220|  1.17k|	if (lenp != NULL)
  ------------------
  |  Branch (220:6): [True: 27, False: 1.14k]
  ------------------
  221|     27|		*lenp = 0;
  222|  1.17k|	if ((r = sshbuf_peek_string_direct(buf, &p, &len)) < 0)
  ------------------
  |  Branch (222:6): [True: 0, False: 1.17k]
  ------------------
  223|      0|		return r;
  224|  1.17k|	if (valp != NULL)
  ------------------
  |  Branch (224:6): [True: 27, False: 1.14k]
  ------------------
  225|     27|		*valp = p;
  226|  1.17k|	if (lenp != NULL)
  ------------------
  |  Branch (226:6): [True: 27, False: 1.14k]
  ------------------
  227|     27|		*lenp = len;
  228|  1.17k|	if (sshbuf_consume(buf, len + 4) != 0) {
  ------------------
  |  Branch (228:6): [True: 0, False: 1.17k]
  ------------------
  229|       |		/* Shouldn't happen */
  230|      0|		SSHBUF_DBG(("SSH_ERR_INTERNAL_ERROR"));
  231|      0|		SSHBUF_ABORT();
  232|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  233|      0|	}
  234|  1.17k|	return 0;
  235|  1.17k|}
sshbuf_peek_string_direct:
  240|  2.43k|{
  241|  2.43k|	uint32_t len;
  242|  2.43k|	const u_char *p = sshbuf_ptr(buf);
  243|       |
  244|  2.43k|	if (valp != NULL)
  ------------------
  |  Branch (244:6): [True: 2.43k, False: 0]
  ------------------
  245|  2.43k|		*valp = NULL;
  246|  2.43k|	if (lenp != NULL)
  ------------------
  |  Branch (246:6): [True: 2.43k, False: 0]
  ------------------
  247|  2.43k|		*lenp = 0;
  248|  2.43k|	if (sshbuf_len(buf) < 4) {
  ------------------
  |  Branch (248:6): [True: 28, False: 2.40k]
  ------------------
  249|     28|		SSHBUF_DBG(("SSH_ERR_MESSAGE_INCOMPLETE"));
  250|     28|		return SSH_ERR_MESSAGE_INCOMPLETE;
  ------------------
  |  |   27|     28|#define SSH_ERR_MESSAGE_INCOMPLETE		-3
  ------------------
  251|     28|	}
  252|  2.40k|	len = PEEK_U32(p);
  ------------------
  |  |  351|  2.40k|	(((uint32_t)(((const u_char *)(p))[0]) << 24) | \
  |  |  352|  2.40k|	 ((uint32_t)(((const u_char *)(p))[1]) << 16) | \
  |  |  353|  2.40k|	 ((uint32_t)(((const u_char *)(p))[2]) << 8) | \
  |  |  354|  2.40k|	  (uint32_t)(((const u_char *)(p))[3]))
  ------------------
  253|  2.40k|	if (len > SSHBUF_SIZE_MAX - 4) {
  ------------------
  |  |   39|  2.40k|#define SSHBUF_SIZE_MAX		0x8000000	/* Hard maximum size */
  ------------------
  |  Branch (253:6): [True: 31, False: 2.37k]
  ------------------
  254|     31|		SSHBUF_DBG(("SSH_ERR_STRING_TOO_LARGE"));
  255|     31|		return SSH_ERR_STRING_TOO_LARGE;
  ------------------
  |  |   30|     31|#define SSH_ERR_STRING_TOO_LARGE		-6
  ------------------
  256|     31|	}
  257|  2.37k|	if (sshbuf_len(buf) - 4 < len) {
  ------------------
  |  Branch (257:6): [True: 46, False: 2.32k]
  ------------------
  258|     46|		SSHBUF_DBG(("SSH_ERR_MESSAGE_INCOMPLETE"));
  259|     46|		return SSH_ERR_MESSAGE_INCOMPLETE;
  ------------------
  |  |   27|     46|#define SSH_ERR_MESSAGE_INCOMPLETE		-3
  ------------------
  260|     46|	}
  261|  2.32k|	if (valp != NULL)
  ------------------
  |  Branch (261:6): [True: 2.32k, False: 0]
  ------------------
  262|  2.32k|		*valp = p + 4;
  263|  2.32k|	if (lenp != NULL)
  ------------------
  |  Branch (263:6): [True: 2.32k, False: 0]
  ------------------
  264|  2.32k|		*lenp = len;
  265|  2.32k|	return 0;
  266|  2.37k|}
sshbuf_get_cstring:
  270|  1.23k|{
  271|  1.23k|	size_t len;
  272|  1.23k|	const u_char *p, *z;
  273|  1.23k|	int r;
  274|       |
  275|  1.23k|	if (valp != NULL)
  ------------------
  |  Branch (275:6): [True: 1.22k, False: 15]
  ------------------
  276|  1.22k|		*valp = NULL;
  277|  1.23k|	if (lenp != NULL)
  ------------------
  |  Branch (277:6): [True: 34, False: 1.20k]
  ------------------
  278|     34|		*lenp = 0;
  279|  1.23k|	if ((r = sshbuf_peek_string_direct(buf, &p, &len)) != 0)
  ------------------
  |  Branch (279:6): [True: 88, False: 1.14k]
  ------------------
  280|     88|		return r;
  281|       |	/* Allow a \0 only at the end of the string */
  282|  1.14k|	if (len > 0 &&
  ------------------
  |  Branch (282:6): [True: 495, False: 652]
  ------------------
  283|    495|	    (z = memchr(p , '\0', len)) != NULL && z < p + len - 1) {
  ------------------
  |  Branch (283:6): [True: 107, False: 388]
  |  Branch (283:45): [True: 2, False: 105]
  ------------------
  284|      2|		SSHBUF_DBG(("SSH_ERR_INVALID_FORMAT"));
  285|      2|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      2|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  286|      2|	}
  287|  1.14k|	if ((r = sshbuf_skip_string(buf)) != 0)
  ------------------
  |  |  232|  1.14k|#define sshbuf_skip_string(buf) sshbuf_get_string_direct(buf, NULL, NULL)
  ------------------
  |  Branch (287:6): [True: 0, False: 1.14k]
  ------------------
  288|      0|		return -1;
  289|  1.14k|	if (valp != NULL) {
  ------------------
  |  Branch (289:6): [True: 1.13k, False: 9]
  ------------------
  290|  1.13k|		if ((*valp = malloc(len + 1)) == NULL) {
  ------------------
  |  Branch (290:7): [True: 0, False: 1.13k]
  ------------------
  291|      0|			SSHBUF_DBG(("SSH_ERR_ALLOC_FAIL"));
  292|      0|			return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  293|      0|		}
  294|  1.13k|		if (len != 0)
  ------------------
  |  Branch (294:7): [True: 493, False: 643]
  ------------------
  295|    493|			memcpy(*valp, p, len);
  296|  1.13k|		(*valp)[len] = '\0';
  297|  1.13k|	}
  298|  1.14k|	if (lenp != NULL)
  ------------------
  |  Branch (298:6): [True: 28, False: 1.11k]
  ------------------
  299|     28|		*lenp = (size_t)len;
  300|  1.14k|	return 0;
  301|  1.14k|}
sshbuf_put:
  325|  2.67k|{
  326|  2.67k|	u_char *p;
  327|  2.67k|	int r;
  328|       |
  329|  2.67k|	if ((r = sshbuf_reserve(buf, len, &p)) < 0)
  ------------------
  |  Branch (329:6): [True: 0, False: 2.67k]
  ------------------
  330|      0|		return r;
  331|  2.67k|	if (len != 0)
  ------------------
  |  Branch (331:6): [True: 2.67k, False: 0]
  ------------------
  332|  2.67k|		memcpy(p, v, len);
  333|  2.67k|	return 0;
  334|  2.67k|}
sshbuf_putb:
  338|     12|{
  339|     12|	if (v == NULL)
  ------------------
  |  Branch (339:6): [True: 0, False: 12]
  ------------------
  340|      0|		return 0;
  341|     12|	return sshbuf_put(buf, sshbuf_ptr(v), sshbuf_len(v));
  342|     12|}
sshbuf_putf:
  346|  1.18k|{
  347|  1.18k|	va_list ap;
  348|  1.18k|	int r;
  349|       |
  350|  1.18k|	va_start(ap, fmt);
  351|  1.18k|	r = sshbuf_putfv(buf, fmt, ap);
  352|       |	va_end(ap);
  353|  1.18k|	return r;
  354|  1.18k|}
sshbuf_putfv:
  358|  1.18k|{
  359|  1.18k|	va_list ap2;
  360|  1.18k|	int r, len;
  361|  1.18k|	u_char *p;
  362|       |
  363|  1.18k|	VA_COPY(ap2, ap);
  ------------------
  |  |  311|  1.18k|#  define VA_COPY(dest, src) va_copy(dest, src)
  ------------------
  364|  1.18k|	if ((len = vsnprintf(NULL, 0, fmt, ap2)) < 0) {
  ------------------
  |  Branch (364:6): [True: 0, False: 1.18k]
  ------------------
  365|      0|		r = SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  366|      0|		goto out;
  367|      0|	}
  368|  1.18k|	if (len == 0) {
  ------------------
  |  Branch (368:6): [True: 0, False: 1.18k]
  ------------------
  369|      0|		r = 0;
  370|      0|		goto out; /* Nothing to do */
  371|      0|	}
  372|  1.18k|	va_end(ap2);
  373|  1.18k|	VA_COPY(ap2, ap);
  ------------------
  |  |  311|  1.18k|#  define VA_COPY(dest, src) va_copy(dest, src)
  ------------------
  374|  1.18k|	if ((r = sshbuf_reserve(buf, (size_t)len + 1, &p)) < 0)
  ------------------
  |  Branch (374:6): [True: 0, False: 1.18k]
  ------------------
  375|      0|		goto out;
  376|  1.18k|	if ((r = vsnprintf((char *)p, len + 1, fmt, ap2)) != len) {
  ------------------
  |  Branch (376:6): [True: 0, False: 1.18k]
  ------------------
  377|      0|		r = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  378|      0|		goto out; /* Shouldn't happen */
  379|      0|	}
  380|       |	/* Consume terminating \0 */
  381|  1.18k|	if ((r = sshbuf_consume_end(buf, 1)) != 0)
  ------------------
  |  Branch (381:6): [True: 0, False: 1.18k]
  ------------------
  382|      0|		goto out;
  383|  1.18k|	r = 0;
  384|  1.18k| out:
  385|       |	va_end(ap2);
  386|  1.18k|	return r;
  387|  1.18k|}
sshbuf_put_u32:
  403|     12|{
  404|     12|	u_char *p;
  405|     12|	int r;
  406|       |
  407|     12|	if ((r = sshbuf_reserve(buf, 4, &p)) < 0)
  ------------------
  |  Branch (407:6): [True: 0, False: 12]
  ------------------
  408|      0|		return r;
  409|     12|	POKE_U32(p, val);
  ------------------
  |  |  372|     12|	do { \
  |  |  373|     12|		const uint32_t __v = (v); \
  |  |  374|     12|		((u_char *)(p))[0] = (__v >> 24) & 0xff; \
  |  |  375|     12|		((u_char *)(p))[1] = (__v >> 16) & 0xff; \
  |  |  376|     12|		((u_char *)(p))[2] = (__v >> 8) & 0xff; \
  |  |  377|     12|		((u_char *)(p))[3] = __v & 0xff; \
  |  |  378|     12|	} while (0)
  |  |  ------------------
  |  |  |  Branch (378:11): [Folded, False: 12]
  |  |  ------------------
  ------------------
  410|     12|	return 0;
  411|     12|}
sshbuf_put_u8:
  427|    754|{
  428|    754|	u_char *p;
  429|    754|	int r;
  430|       |
  431|    754|	if ((r = sshbuf_reserve(buf, 1, &p)) < 0)
  ------------------
  |  Branch (431:6): [True: 0, False: 754]
  ------------------
  432|      0|		return r;
  433|    754|	p[0] = val;
  434|    754|	return 0;
  435|    754|}
sshbuf_put_string:
  513|    383|{
  514|    383|	u_char *d;
  515|    383|	int r;
  516|       |
  517|    383|	if (len > SSHBUF_SIZE_MAX - 4) {
  ------------------
  |  |   39|    383|#define SSHBUF_SIZE_MAX		0x8000000	/* Hard maximum size */
  ------------------
  |  Branch (517:6): [True: 0, False: 383]
  ------------------
  518|      0|		SSHBUF_DBG(("SSH_ERR_NO_BUFFER_SPACE"));
  519|      0|		return SSH_ERR_NO_BUFFER_SPACE;
  ------------------
  |  |   33|      0|#define SSH_ERR_NO_BUFFER_SPACE			-9
  ------------------
  520|      0|	}
  521|    383|	if ((r = sshbuf_reserve(buf, len + 4, &d)) < 0)
  ------------------
  |  Branch (521:6): [True: 0, False: 383]
  ------------------
  522|      0|		return r;
  523|    383|	POKE_U32(d, len);
  ------------------
  |  |  372|    383|	do { \
  |  |  373|    383|		const uint32_t __v = (v); \
  |  |  374|    383|		((u_char *)(p))[0] = (__v >> 24) & 0xff; \
  |  |  375|    383|		((u_char *)(p))[1] = (__v >> 16) & 0xff; \
  |  |  376|    383|		((u_char *)(p))[2] = (__v >> 8) & 0xff; \
  |  |  377|    383|		((u_char *)(p))[3] = __v & 0xff; \
  |  |  378|    383|	} while (0)
  |  |  ------------------
  |  |  |  Branch (378:11): [Folded, False: 383]
  |  |  ------------------
  ------------------
  524|    383|	if (len != 0)
  ------------------
  |  Branch (524:6): [True: 371, False: 12]
  ------------------
  525|    371|		memcpy(d + 4, v, len);
  526|    383|	return 0;
  527|    383|}
sshbuf_put_cstring:
  531|    367|{
  532|    367|	return sshbuf_put_string(buf, v, v == NULL ? 0 : strlen(v));
  ------------------
  |  Branch (532:35): [True: 0, False: 367]
  ------------------
  533|    367|}
sshbuf_put_stringb:
  537|     13|{
  538|     13|	if (v == NULL)
  ------------------
  |  Branch (538:6): [True: 0, False: 13]
  ------------------
  539|      0|		return sshbuf_put_string(buf, NULL, 0);
  540|       |
  541|     13|	return sshbuf_put_string(buf, sshbuf_ptr(v), sshbuf_len(v));
  542|     13|}
sshbuf_froms:
  546|     25|{
  547|     25|	const u_char *p;
  548|     25|	size_t len;
  549|     25|	struct sshbuf *ret;
  550|     25|	int r;
  551|       |
  552|     25|	if (buf == NULL || bufp == NULL)
  ------------------
  |  Branch (552:6): [True: 0, False: 25]
  |  Branch (552:21): [True: 0, False: 25]
  ------------------
  553|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  554|     25|	*bufp = NULL;
  555|     25|	if ((r = sshbuf_peek_string_direct(buf, &p, &len)) != 0)
  ------------------
  |  Branch (555:6): [True: 17, False: 8]
  ------------------
  556|     17|		return r;
  557|      8|	if ((ret = sshbuf_from(p, len)) == NULL)
  ------------------
  |  Branch (557:6): [True: 0, False: 8]
  ------------------
  558|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  559|      8|	if ((r = sshbuf_consume(buf, len + 4)) != 0 ||  /* Shouldn't happen */
  ------------------
  |  Branch (559:6): [True: 0, False: 8]
  ------------------
  560|      8|	    (r = sshbuf_set_parent(ret, buf)) != 0) {
  ------------------
  |  Branch (560:6): [True: 0, False: 8]
  ------------------
  561|      0|		sshbuf_free(ret);
  562|      0|		return r;
  563|      0|	}
  564|      8|	*bufp = ret;
  565|      8|	return 0;
  566|      8|}
sshbuf_put_bignum2_bytes:
  570|      2|{
  571|      2|	u_char *d;
  572|      2|	const u_char *s = (const u_char *)v;
  573|      2|	int r, prepend;
  574|       |
  575|      2|	if (len > SSHBUF_SIZE_MAX - 5) {
  ------------------
  |  |   39|      2|#define SSHBUF_SIZE_MAX		0x8000000	/* Hard maximum size */
  ------------------
  |  Branch (575:6): [True: 0, False: 2]
  ------------------
  576|      0|		SSHBUF_DBG(("SSH_ERR_NO_BUFFER_SPACE"));
  577|      0|		return SSH_ERR_NO_BUFFER_SPACE;
  ------------------
  |  |   33|      0|#define SSH_ERR_NO_BUFFER_SPACE			-9
  ------------------
  578|      0|	}
  579|       |	/* Skip leading zero bytes */
  580|      2|	for (; len > 0 && *s == 0; len--, s++)
  ------------------
  |  Branch (580:9): [True: 2, False: 0]
  |  Branch (580:20): [True: 0, False: 2]
  ------------------
  581|      0|		;
  582|       |	/*
  583|       |	 * If most significant bit is set then prepend a zero byte to
  584|       |	 * avoid interpretation as a negative number.
  585|       |	 */
  586|      2|	prepend = len > 0 && (s[0] & 0x80) != 0;
  ------------------
  |  Branch (586:12): [True: 2, False: 0]
  |  Branch (586:23): [True: 2, False: 0]
  ------------------
  587|      2|	if ((r = sshbuf_reserve(buf, len + 4 + prepend, &d)) < 0)
  ------------------
  |  Branch (587:6): [True: 0, False: 2]
  ------------------
  588|      0|		return r;
  589|      2|	POKE_U32(d, len + prepend);
  ------------------
  |  |  372|      2|	do { \
  |  |  373|      2|		const uint32_t __v = (v); \
  |  |  374|      2|		((u_char *)(p))[0] = (__v >> 24) & 0xff; \
  |  |  375|      2|		((u_char *)(p))[1] = (__v >> 16) & 0xff; \
  |  |  376|      2|		((u_char *)(p))[2] = (__v >> 8) & 0xff; \
  |  |  377|      2|		((u_char *)(p))[3] = __v & 0xff; \
  |  |  378|      2|	} while (0)
  |  |  ------------------
  |  |  |  Branch (378:11): [Folded, False: 2]
  |  |  ------------------
  ------------------
  590|      2|	if (prepend)
  ------------------
  |  Branch (590:6): [True: 2, False: 0]
  ------------------
  591|      2|		d[4] = 0;
  592|      2|	if (len != 0)
  ------------------
  |  Branch (592:6): [True: 2, False: 0]
  ------------------
  593|      2|		memcpy(d + 4 + prepend, s, len);
  594|      2|	return 0;
  595|      2|}

sshbuf_b64tod:
  184|      2|{
  185|      2|	size_t plen = strlen(b64);
  186|      2|	int nlen, r;
  187|      2|	u_char *p;
  188|       |
  189|      2|	if (plen == 0)
  ------------------
  |  Branch (189:6): [True: 0, False: 2]
  ------------------
  190|      0|		return 0;
  191|      2|	if ((p = malloc(plen)) == NULL)
  ------------------
  |  Branch (191:6): [True: 0, False: 2]
  ------------------
  192|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  193|      2|	if ((nlen = b64_pton(b64, p, plen)) < 0) {
  ------------------
  |  Branch (193:6): [True: 0, False: 2]
  ------------------
  194|      0|		freezero(p, plen);
  195|      0|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  196|      0|	}
  197|      2|	if ((r = sshbuf_put(buf, p, nlen)) < 0) {
  ------------------
  |  Branch (197:6): [True: 0, False: 2]
  ------------------
  198|      0|		freezero(p, plen);
  199|      0|		return r;
  200|      0|	}
  201|      2|	freezero(p, plen);
  202|      2|	return 0;
  203|      2|}
sshbuf_dup_string:
  253|    299|{
  254|    299|	const u_char *p = NULL, *s = sshbuf_ptr(buf);
  255|    299|	size_t l = sshbuf_len(buf);
  256|    299|	char *r;
  257|       |
  258|    299|	if (s == NULL || l >= SIZE_MAX)
  ------------------
  |  Branch (258:6): [True: 0, False: 299]
  |  Branch (258:19): [True: 0, False: 299]
  ------------------
  259|      0|		return NULL;
  260|       |	/* accept a nul only as the last character in the buffer */
  261|    299|	if (l > 0 && (p = memchr(s, '\0', l)) != NULL) {
  ------------------
  |  Branch (261:6): [True: 299, False: 0]
  |  Branch (261:15): [True: 0, False: 299]
  ------------------
  262|      0|		if (p != s + l - 1)
  ------------------
  |  Branch (262:7): [True: 0, False: 0]
  ------------------
  263|      0|			return NULL;
  264|      0|		l--; /* the nul is put back below */
  265|      0|	}
  266|    299|	if ((r = malloc(l + 1)) == NULL)
  ------------------
  |  Branch (266:6): [True: 0, False: 299]
  ------------------
  267|      0|		return NULL;
  268|    299|	if (l > 0)
  ------------------
  |  Branch (268:6): [True: 299, False: 0]
  ------------------
  269|    299|		memcpy(r, s, l);
  270|    299|	r[l] = '\0';
  271|    299|	return r;
  272|    299|}

sshbuf_new:
   94|    329|{
   95|    329|	struct sshbuf *ret;
   96|       |
   97|    329|	if ((ret = calloc(1, sizeof(*ret))) == NULL)
  ------------------
  |  Branch (97:6): [True: 0, False: 329]
  ------------------
   98|      0|		return NULL;
   99|    329|	ret->alloc = SSHBUF_SIZE_INIT;
  ------------------
  |  |  409|    329|# define SSHBUF_SIZE_INIT	256		/* Initial allocation */
  ------------------
  100|    329|	ret->max_size = SSHBUF_SIZE_MAX;
  ------------------
  |  |   39|    329|#define SSHBUF_SIZE_MAX		0x8000000	/* Hard maximum size */
  ------------------
  101|    329|	ret->readonly = 0;
  102|    329|	ret->refcount = 1;
  103|    329|	ret->parent = NULL;
  104|    329|	if ((ret->cd = ret->d = calloc(1, ret->alloc)) == NULL) {
  ------------------
  |  Branch (104:6): [True: 0, False: 329]
  ------------------
  105|      0|		free(ret);
  106|      0|		return NULL;
  107|      0|	}
  108|    329|	return ret;
  109|    329|}
sshbuf_from:
  113|     22|{
  114|     22|	struct sshbuf *ret;
  115|       |
  116|     22|	if (blob == NULL || len > SSHBUF_SIZE_MAX ||
  ------------------
  |  |   39|     44|#define SSHBUF_SIZE_MAX		0x8000000	/* Hard maximum size */
  ------------------
  |  Branch (116:6): [True: 0, False: 22]
  |  Branch (116:22): [True: 0, False: 22]
  ------------------
  117|     22|	    (ret = calloc(1, sizeof(*ret))) == NULL)
  ------------------
  |  Branch (117:6): [True: 0, False: 22]
  ------------------
  118|      0|		return NULL;
  119|     22|	ret->alloc = ret->size = ret->max_size = len;
  120|     22|	ret->readonly = 1;
  121|     22|	ret->refcount = 1;
  122|     22|	ret->parent = NULL;
  123|     22|	ret->cd = blob;
  124|       |	ret->d = NULL;
  125|     22|	return ret;
  126|     22|}
sshbuf_set_parent:
  130|     20|{
  131|     20|	int r;
  132|       |
  133|     20|	if ((r = sshbuf_check_sanity(child)) != 0 ||
  ------------------
  |  Branch (133:6): [True: 0, False: 20]
  ------------------
  134|     20|	    (r = sshbuf_check_sanity(parent)) != 0)
  ------------------
  |  Branch (134:6): [True: 0, False: 20]
  ------------------
  135|      0|		return r;
  136|     20|	if ((child->parent != NULL && child->parent != parent) ||
  ------------------
  |  Branch (136:7): [True: 0, False: 20]
  |  Branch (136:32): [True: 0, False: 0]
  ------------------
  137|     20|	    child == parent)
  ------------------
  |  Branch (137:6): [True: 0, False: 20]
  ------------------
  138|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  139|     20|	child->parent = parent;
  140|     20|	child->parent->refcount++;
  141|     20|	return 0;
  142|     20|}
sshbuf_fromb:
  146|     12|{
  147|     12|	struct sshbuf *ret;
  148|       |
  149|     12|	if (sshbuf_check_sanity(buf) != 0)
  ------------------
  |  Branch (149:6): [True: 0, False: 12]
  ------------------
  150|      0|		return NULL;
  151|     12|	if ((ret = sshbuf_from(sshbuf_ptr(buf), sshbuf_len(buf))) == NULL)
  ------------------
  |  Branch (151:6): [True: 0, False: 12]
  ------------------
  152|      0|		return NULL;
  153|     12|	if (sshbuf_set_parent(ret, buf) != 0) {
  ------------------
  |  Branch (153:6): [True: 0, False: 12]
  ------------------
  154|      0|		sshbuf_free(ret);
  155|      0|		return NULL;
  156|      0|	}
  157|     12|	return ret;
  158|     12|}
sshbuf_free:
  162|  1.18k|{
  163|  1.18k|	if (buf == NULL)
  ------------------
  |  Branch (163:6): [True: 833, False: 349]
  ------------------
  164|    833|		return;
  165|       |	/*
  166|       |	 * The following will leak on insane buffers, but this is the safest
  167|       |	 * course of action - an invalid pointer or already-freed pointer may
  168|       |	 * have been passed to us and continuing to scribble over memory would
  169|       |	 * be bad.
  170|       |	 */
  171|    349|	if (sshbuf_check_sanity(buf) != 0)
  ------------------
  |  Branch (171:6): [True: 0, False: 349]
  ------------------
  172|      0|		return;
  173|       |
  174|       |	/*
  175|       |	 * If we are a parent with still-extant children, then don't free just
  176|       |	 * yet. The last child's call to sshbuf_free should decrement our
  177|       |	 * refcount to 0 and trigger the actual free.
  178|       |	 */
  179|    349|	buf->refcount--;
  180|    349|	if (buf->refcount > 0)
  ------------------
  |  Branch (180:6): [True: 19, False: 330]
  ------------------
  181|     19|		return;
  182|       |
  183|       |	/*
  184|       |	 * If we are a child, then free our parent to decrement its reference
  185|       |	 * count and possibly free it.
  186|       |	 */
  187|    330|	sshbuf_free(buf->parent);
  188|    330|	buf->parent = NULL;
  189|       |
  190|    330|	if (!buf->readonly)
  ------------------
  |  Branch (190:6): [True: 309, False: 21]
  ------------------
  191|    309|		freezero(buf->d, buf->alloc);
  192|    330|	freezero(buf, sizeof(*buf));
  193|    330|}
sshbuf_reset:
  197|  2.16k|{
  198|  2.16k|	u_char *d;
  199|       |
  200|  2.16k|	if (buf->readonly || buf->refcount > 1) {
  ------------------
  |  Branch (200:6): [True: 0, False: 2.16k]
  |  Branch (200:23): [True: 107, False: 2.05k]
  ------------------
  201|       |		/* Nonsensical. Just make buffer appear empty */
  202|    107|		buf->off = buf->size;
  203|    107|		return;
  204|    107|	}
  205|  2.05k|	if (sshbuf_check_sanity(buf) != 0)
  ------------------
  |  Branch (205:6): [True: 0, False: 2.05k]
  ------------------
  206|      0|		return;
  207|  2.05k|	buf->off = buf->size = 0;
  208|  2.05k|	if (buf->alloc != SSHBUF_SIZE_INIT) {
  ------------------
  |  |  409|  2.05k|# define SSHBUF_SIZE_INIT	256		/* Initial allocation */
  ------------------
  |  Branch (208:6): [True: 91, False: 1.96k]
  ------------------
  209|     91|		if ((d = recallocarray(buf->d, buf->alloc, SSHBUF_SIZE_INIT,
  ------------------
  |  |  409|     91|# define SSHBUF_SIZE_INIT	256		/* Initial allocation */
  ------------------
  |  Branch (209:7): [True: 91, False: 0]
  ------------------
  210|     91|		    1)) != NULL) {
  211|     91|			buf->cd = buf->d = d;
  212|     91|			buf->alloc = SSHBUF_SIZE_INIT;
  ------------------
  |  |  409|     91|# define SSHBUF_SIZE_INIT	256		/* Initial allocation */
  ------------------
  213|     91|		}
  214|     91|	}
  215|  2.05k|	explicit_bzero(buf->d, buf->alloc);
  216|  2.05k|}
sshbuf_len:
  282|  19.6k|{
  283|  19.6k|	if (sshbuf_check_sanity(buf) != 0)
  ------------------
  |  Branch (283:6): [True: 0, False: 19.6k]
  ------------------
  284|      0|		return 0;
  285|  19.6k|	return buf->size - buf->off;
  286|  19.6k|}
sshbuf_ptr:
  298|  10.8k|{
  299|  10.8k|	if (sshbuf_check_sanity(buf) != 0)
  ------------------
  |  Branch (299:6): [True: 0, False: 10.8k]
  ------------------
  300|      0|		return NULL;
  301|  10.8k|	return buf->cd + buf->off;
  302|  10.8k|}
sshbuf_mutable_ptr:
  306|    818|{
  307|    818|	if (sshbuf_check_sanity(buf) != 0 || buf->readonly || buf->refcount > 1)
  ------------------
  |  Branch (307:6): [True: 0, False: 818]
  |  Branch (307:39): [True: 0, False: 818]
  |  Branch (307:56): [True: 0, False: 818]
  ------------------
  308|      0|		return NULL;
  309|    818|	return buf->d + buf->off;
  310|    818|}
sshbuf_check_reserve:
  314|  7.96k|{
  315|  7.96k|	int r;
  316|       |
  317|  7.96k|	if ((r = sshbuf_check_sanity(buf)) != 0)
  ------------------
  |  Branch (317:6): [True: 0, False: 7.96k]
  ------------------
  318|      0|		return r;
  319|  7.96k|	if (buf->readonly || buf->refcount > 1)
  ------------------
  |  Branch (319:6): [True: 0, False: 7.96k]
  |  Branch (319:23): [True: 107, False: 7.85k]
  ------------------
  320|    107|		return SSH_ERR_BUFFER_READ_ONLY;
  ------------------
  |  |   73|    107|#define SSH_ERR_BUFFER_READ_ONLY		-49
  ------------------
  321|  7.85k|	SSHBUF_TELL("check");
  322|       |	/* Check that len is reasonable and that max_size + available < len */
  323|  7.85k|	if (len > buf->max_size || buf->max_size - len < buf->size - buf->off)
  ------------------
  |  Branch (323:6): [True: 0, False: 7.85k]
  |  Branch (323:29): [True: 0, False: 7.85k]
  ------------------
  324|      0|		return SSH_ERR_NO_BUFFER_SPACE;
  ------------------
  |  |   33|      0|#define SSH_ERR_NO_BUFFER_SPACE			-9
  ------------------
  325|  7.85k|	return 0;
  326|  7.85k|}
sshbuf_allocate:
  330|  7.58k|{
  331|  7.58k|	size_t rlen, need;
  332|  7.58k|	u_char *dp;
  333|  7.58k|	int r;
  334|       |
  335|  7.58k|	SSHBUF_DBG(("allocate buf = %p len = %zu", buf, len));
  336|  7.58k|	if ((r = sshbuf_check_reserve(buf, len)) != 0)
  ------------------
  |  Branch (336:6): [True: 107, False: 7.47k]
  ------------------
  337|    107|		return r;
  338|       |	/*
  339|       |	 * If the requested allocation appended would push us past max_size
  340|       |	 * then pack the buffer, zeroing buf->off.
  341|       |	 */
  342|  7.47k|	sshbuf_maybe_pack(buf, buf->size + len > buf->max_size);
  343|  7.47k|	SSHBUF_TELL("allocate");
  344|  7.47k|	if (len + buf->size <= buf->alloc)
  ------------------
  |  Branch (344:6): [True: 7.08k, False: 384]
  ------------------
  345|  7.08k|		return 0; /* already have it. */
  346|       |
  347|       |	/*
  348|       |	 * Prefer to alloc in SSHBUF_SIZE_INC units, but
  349|       |	 * allocate less if doing so would overflow max_size.
  350|       |	 */
  351|    384|	need = len + buf->size - buf->alloc;
  352|    384|	rlen = ROUNDUP(buf->alloc + need, SSHBUF_SIZE_INC);
  ------------------
  |  |  270|    384|#define ROUNDUP(x, y)   ((((x)+((y)-1))/(y))*(y))
  ------------------
  353|    384|	SSHBUF_DBG(("need %zu initial rlen %zu", need, rlen));
  354|    384|	if (rlen > buf->max_size)
  ------------------
  |  Branch (354:6): [True: 0, False: 384]
  ------------------
  355|      0|		rlen = buf->alloc + need;
  356|    384|	SSHBUF_DBG(("adjusted rlen %zu", rlen));
  357|    384|	if ((dp = recallocarray(buf->d, buf->alloc, rlen, 1)) == NULL) {
  ------------------
  |  Branch (357:6): [True: 0, False: 384]
  ------------------
  358|      0|		SSHBUF_DBG(("realloc fail"));
  359|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  360|      0|	}
  361|    384|	buf->alloc = rlen;
  362|    384|	buf->cd = buf->d = dp;
  363|    384|	if ((r = sshbuf_check_reserve(buf, len)) < 0) {
  ------------------
  |  Branch (363:6): [True: 0, False: 384]
  ------------------
  364|       |		/* shouldn't fail */
  365|      0|		return r;
  366|      0|	}
  367|    384|	SSHBUF_TELL("done");
  368|    384|	return 0;
  369|    384|}
sshbuf_reserve:
  373|  7.58k|{
  374|  7.58k|	u_char *dp;
  375|  7.58k|	int r;
  376|       |
  377|  7.58k|	if (dpp != NULL)
  ------------------
  |  Branch (377:6): [True: 7.58k, False: 0]
  ------------------
  378|  7.58k|		*dpp = NULL;
  379|       |
  380|  7.58k|	SSHBUF_DBG(("reserve buf = %p len = %zu", buf, len));
  381|  7.58k|	if ((r = sshbuf_allocate(buf, len)) != 0)
  ------------------
  |  Branch (381:6): [True: 107, False: 7.47k]
  ------------------
  382|    107|		return r;
  383|       |
  384|  7.47k|	dp = buf->d + buf->size;
  385|  7.47k|	buf->size += len;
  386|  7.47k|	if (dpp != NULL)
  ------------------
  |  Branch (386:6): [True: 7.47k, False: 0]
  ------------------
  387|  7.47k|		*dpp = dp;
  388|  7.47k|	return 0;
  389|  7.58k|}
sshbuf_consume:
  393|  3.87k|{
  394|  3.87k|	int r;
  395|       |
  396|  3.87k|	SSHBUF_DBG(("len = %zu", len));
  397|  3.87k|	if ((r = sshbuf_check_sanity(buf)) != 0)
  ------------------
  |  Branch (397:6): [True: 0, False: 3.87k]
  ------------------
  398|      0|		return r;
  399|  3.87k|	if (len == 0)
  ------------------
  |  Branch (399:6): [True: 58, False: 3.81k]
  ------------------
  400|     58|		return 0;
  401|  3.81k|	if (len > sshbuf_len(buf))
  ------------------
  |  Branch (401:6): [True: 2, False: 3.81k]
  ------------------
  402|      2|		return SSH_ERR_MESSAGE_INCOMPLETE;
  ------------------
  |  |   27|      2|#define SSH_ERR_MESSAGE_INCOMPLETE		-3
  ------------------
  403|  3.81k|	buf->off += len;
  404|       |	/* deal with empty buffer */
  405|  3.81k|	if (buf->off == buf->size)
  ------------------
  |  Branch (405:6): [True: 1.03k, False: 2.77k]
  ------------------
  406|  1.03k|		buf->off = buf->size = 0;
  407|  3.81k|	SSHBUF_TELL("done");
  408|  3.81k|	return 0;
  409|  3.81k|}
sshbuf_consume_end:
  413|  1.59k|{
  414|  1.59k|	int r;
  415|       |
  416|  1.59k|	SSHBUF_DBG(("len = %zu", len));
  417|  1.59k|	if ((r = sshbuf_check_sanity(buf)) != 0)
  ------------------
  |  Branch (417:6): [True: 0, False: 1.59k]
  ------------------
  418|      0|		return r;
  419|  1.59k|	if (len == 0)
  ------------------
  |  Branch (419:6): [True: 0, False: 1.59k]
  ------------------
  420|      0|		return 0;
  421|  1.59k|	if (len > sshbuf_len(buf))
  ------------------
  |  Branch (421:6): [True: 0, False: 1.59k]
  ------------------
  422|      0|		return SSH_ERR_MESSAGE_INCOMPLETE;
  ------------------
  |  |   27|      0|#define SSH_ERR_MESSAGE_INCOMPLETE		-3
  ------------------
  423|  1.59k|	buf->size -= len;
  424|  1.59k|	SSHBUF_TELL("done");
  425|  1.59k|	return 0;
  426|  1.59k|}
sshbuf.c:sshbuf_check_sanity:
   56|  47.2k|{
   57|  47.2k|	SSHBUF_TELL("sanity");
   58|  47.2k|	if (__predict_false(buf == NULL ||
  ------------------
  |  |  986|   943k|#  define __predict_false(exp)    __builtin_expect(((exp) != 0), 0)
  |  |  ------------------
  |  |  |  Branch (986:35): [True: 0, False: 47.2k]
  |  |  |  Branch (986:54): [True: 46.3k, False: 814]
  |  |  |  Branch (986:54): [True: 0, False: 46.3k]
  |  |  |  Branch (986:54): [True: 0, False: 47.2k]
  |  |  |  Branch (986:54): [True: 0, False: 47.2k]
  |  |  |  Branch (986:54): [True: 0, False: 47.2k]
  |  |  |  Branch (986:54): [True: 0, False: 47.2k]
  |  |  |  Branch (986:54): [True: 0, False: 47.2k]
  |  |  |  Branch (986:54): [True: 0, False: 47.2k]
  |  |  |  Branch (986:54): [True: 0, False: 47.2k]
  |  |  |  Branch (986:54): [True: 0, False: 47.2k]
  |  |  |  Branch (986:54): [True: 0, False: 47.2k]
  |  |  ------------------
  ------------------
   59|  47.2k|	    (!buf->readonly && buf->d != buf->cd) ||
   60|  47.2k|	    buf->parent == buf ||
   61|  47.2k|	    buf->refcount < 1 || buf->refcount > SSHBUF_REFS_MAX ||
   62|  47.2k|	    buf->cd == NULL ||
   63|  47.2k|	    buf->max_size > SSHBUF_SIZE_MAX ||
   64|  47.2k|	    buf->alloc > buf->max_size ||
   65|  47.2k|	    buf->size > buf->alloc ||
   66|  47.2k|	    buf->off > buf->size)) {
   67|       |		/* Do not try to recover from corrupted buffer internals */
   68|      0|		SSHBUF_DBG(("SSH_ERR_INTERNAL_ERROR"));
   69|      0|		ssh_signal(SIGSEGV, SIG_DFL);
   70|      0|		raise(SIGSEGV);
   71|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
   72|      0|	}
   73|  47.2k|	return 0;
   74|  47.2k|}
sshbuf.c:sshbuf_maybe_pack:
   78|  7.47k|{
   79|  7.47k|	SSHBUF_DBG(("force %d", force));
   80|  7.47k|	SSHBUF_TELL("pre-pack");
   81|  7.47k|	if (buf->off == 0 || buf->readonly || buf->refcount > 1)
  ------------------
  |  Branch (81:6): [True: 7.47k, False: 1]
  |  Branch (81:23): [True: 0, False: 1]
  |  Branch (81:40): [True: 0, False: 1]
  ------------------
   82|  7.47k|		return;
   83|      1|	if (force ||
  ------------------
  |  Branch (83:6): [True: 0, False: 1]
  ------------------
   84|      1|	    (buf->off >= SSHBUF_PACK_MIN && buf->off >= buf->size / 2)) {
  ------------------
  |  |  411|      2|# define SSHBUF_PACK_MIN	8192		/* Minimum packable offset */
  ------------------
  |  Branch (84:7): [True: 0, False: 1]
  |  Branch (84:38): [True: 0, False: 0]
  ------------------
   85|      0|		memmove(buf->d, buf->d + buf->off, buf->size - buf->off);
   86|      0|		buf->size -= buf->off;
   87|      0|		buf->off = 0;
   88|      0|		SSHBUF_TELL("packed");
   89|      0|	}
   90|      1|}

ssh_err:
   24|     36|{
   25|     36|	const char *msg = NULL;
   26|       |
   27|     36|	switch (n) {
   28|      0|	case SSH_ERR_SUCCESS:
  ------------------
  |  |   24|      0|#define SSH_ERR_SUCCESS				0
  ------------------
  |  Branch (28:2): [True: 0, False: 36]
  ------------------
   29|      0|		return "success";
   30|      0|	case SSH_ERR_INTERNAL_ERROR:
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  |  Branch (30:2): [True: 0, False: 36]
  ------------------
   31|      0|		return "unexpected internal error";
   32|      0|	case SSH_ERR_ALLOC_FAIL:
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  |  Branch (32:2): [True: 0, False: 36]
  ------------------
   33|      0|		return "memory allocation failed";
   34|     22|	case SSH_ERR_MESSAGE_INCOMPLETE:
  ------------------
  |  |   27|     22|#define SSH_ERR_MESSAGE_INCOMPLETE		-3
  ------------------
  |  Branch (34:2): [True: 22, False: 14]
  ------------------
   35|     22|		return "incomplete message";
   36|      1|	case SSH_ERR_INVALID_FORMAT:
  ------------------
  |  |   28|      1|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  |  Branch (36:2): [True: 1, False: 35]
  ------------------
   37|      1|		return "invalid format";
   38|      0|	case SSH_ERR_BIGNUM_IS_NEGATIVE:
  ------------------
  |  |   29|      0|#define SSH_ERR_BIGNUM_IS_NEGATIVE		-5
  ------------------
  |  Branch (38:2): [True: 0, False: 36]
  ------------------
   39|      0|		return "bignum is negative";
   40|     11|	case SSH_ERR_STRING_TOO_LARGE:
  ------------------
  |  |   30|     11|#define SSH_ERR_STRING_TOO_LARGE		-6
  ------------------
  |  Branch (40:2): [True: 11, False: 25]
  ------------------
   41|     11|		return "string is too large";
   42|      0|	case SSH_ERR_BIGNUM_TOO_LARGE:
  ------------------
  |  |   31|      0|#define SSH_ERR_BIGNUM_TOO_LARGE		-7
  ------------------
  |  Branch (42:2): [True: 0, False: 36]
  ------------------
   43|      0|		return "bignum is too large";
   44|      0|	case SSH_ERR_ECPOINT_TOO_LARGE:
  ------------------
  |  |   32|      0|#define SSH_ERR_ECPOINT_TOO_LARGE		-8
  ------------------
  |  Branch (44:2): [True: 0, False: 36]
  ------------------
   45|      0|		return "elliptic curve point is too large";
   46|      0|	case SSH_ERR_NO_BUFFER_SPACE:
  ------------------
  |  |   33|      0|#define SSH_ERR_NO_BUFFER_SPACE			-9
  ------------------
  |  Branch (46:2): [True: 0, False: 36]
  ------------------
   47|      0|		return "insufficient buffer space";
   48|      0|	case SSH_ERR_INVALID_ARGUMENT:
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  |  Branch (48:2): [True: 0, False: 36]
  ------------------
   49|      0|		return "invalid argument";
   50|      0|	case SSH_ERR_KEY_BITS_MISMATCH:
  ------------------
  |  |   35|      0|#define SSH_ERR_KEY_BITS_MISMATCH		-11
  ------------------
  |  Branch (50:2): [True: 0, False: 36]
  ------------------
   51|      0|		return "key bits do not match";
   52|      0|	case SSH_ERR_EC_CURVE_INVALID:
  ------------------
  |  |   36|      0|#define SSH_ERR_EC_CURVE_INVALID		-12
  ------------------
  |  Branch (52:2): [True: 0, False: 36]
  ------------------
   53|      0|		return "invalid elliptic curve";
   54|      0|	case SSH_ERR_KEY_TYPE_MISMATCH:
  ------------------
  |  |   37|      0|#define SSH_ERR_KEY_TYPE_MISMATCH		-13
  ------------------
  |  Branch (54:2): [True: 0, False: 36]
  ------------------
   55|      0|		return "key type does not match";
   56|      0|	case SSH_ERR_KEY_TYPE_UNKNOWN:
  ------------------
  |  |   38|      0|#define SSH_ERR_KEY_TYPE_UNKNOWN		-14 /* XXX UNSUPPORTED? */
  ------------------
  |  Branch (56:2): [True: 0, False: 36]
  ------------------
   57|      0|		return "unknown or unsupported key type";
   58|      0|	case SSH_ERR_EC_CURVE_MISMATCH:
  ------------------
  |  |   39|      0|#define SSH_ERR_EC_CURVE_MISMATCH		-15
  ------------------
  |  Branch (58:2): [True: 0, False: 36]
  ------------------
   59|      0|		return "elliptic curve does not match";
   60|      0|	case SSH_ERR_EXPECTED_CERT:
  ------------------
  |  |   40|      0|#define SSH_ERR_EXPECTED_CERT			-16
  ------------------
  |  Branch (60:2): [True: 0, False: 36]
  ------------------
   61|      0|		return "plain key provided where certificate required";
   62|      0|	case SSH_ERR_KEY_LACKS_CERTBLOB:
  ------------------
  |  |   41|      0|#define SSH_ERR_KEY_LACKS_CERTBLOB		-17
  ------------------
  |  Branch (62:2): [True: 0, False: 36]
  ------------------
   63|      0|		return "key lacks certificate data";
   64|      0|	case SSH_ERR_KEY_CERT_UNKNOWN_TYPE:
  ------------------
  |  |   42|      0|#define SSH_ERR_KEY_CERT_UNKNOWN_TYPE		-18
  ------------------
  |  Branch (64:2): [True: 0, False: 36]
  ------------------
   65|      0|		return "unknown/unsupported certificate type";
   66|      0|	case SSH_ERR_KEY_CERT_INVALID_SIGN_KEY:
  ------------------
  |  |   43|      0|#define SSH_ERR_KEY_CERT_INVALID_SIGN_KEY	-19
  ------------------
  |  Branch (66:2): [True: 0, False: 36]
  ------------------
   67|      0|		return "invalid certificate signing key";
   68|      0|	case SSH_ERR_KEY_INVALID_EC_VALUE:
  ------------------
  |  |   44|      0|#define SSH_ERR_KEY_INVALID_EC_VALUE		-20
  ------------------
  |  Branch (68:2): [True: 0, False: 36]
  ------------------
   69|      0|		return "invalid elliptic curve value";
   70|      0|	case SSH_ERR_SIGNATURE_INVALID:
  ------------------
  |  |   45|      0|#define SSH_ERR_SIGNATURE_INVALID		-21
  ------------------
  |  Branch (70:2): [True: 0, False: 36]
  ------------------
   71|      0|		return "incorrect signature";
   72|      0|	case SSH_ERR_LIBCRYPTO_ERROR:
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  |  Branch (72:2): [True: 0, False: 36]
  ------------------
   73|      0|		msg = ssherr_libcrypto();
   74|      0|		return msg != NULL ? msg : "error in libcrypto";
  ------------------
  |  Branch (74:10): [True: 0, False: 0]
  ------------------
   75|      0|	case SSH_ERR_INTERNAL_CRYPTO_ERROR:
  ------------------
  |  |   86|      0|#define SSH_ERR_INTERNAL_CRYPTO_ERROR		-62
  ------------------
  |  Branch (75:2): [True: 0, False: 36]
  ------------------
   76|      0|		return "cryptographic operation failed";
   77|      2|	case SSH_ERR_UNEXPECTED_TRAILING_DATA:
  ------------------
  |  |   47|      2|#define SSH_ERR_UNEXPECTED_TRAILING_DATA	-23
  ------------------
  |  Branch (77:2): [True: 2, False: 34]
  ------------------
   78|      2|		return "unexpected bytes remain after decoding";
   79|      0|	case SSH_ERR_SYSTEM_ERROR:
  ------------------
  |  |   48|      0|#define SSH_ERR_SYSTEM_ERROR			-24
  ------------------
  |  Branch (79:2): [True: 0, False: 36]
  ------------------
   80|      0|		return strerror(errno);
   81|      0|	case SSH_ERR_KEY_CERT_INVALID:
  ------------------
  |  |   49|      0|#define SSH_ERR_KEY_CERT_INVALID		-25
  ------------------
  |  Branch (81:2): [True: 0, False: 36]
  ------------------
   82|      0|		return "invalid certificate";
   83|      0|	case SSH_ERR_AGENT_COMMUNICATION:
  ------------------
  |  |   50|      0|#define SSH_ERR_AGENT_COMMUNICATION		-26
  ------------------
  |  Branch (83:2): [True: 0, False: 36]
  ------------------
   84|      0|		return "communication with agent failed";
   85|      0|	case SSH_ERR_AGENT_FAILURE:
  ------------------
  |  |   51|      0|#define SSH_ERR_AGENT_FAILURE			-27
  ------------------
  |  Branch (85:2): [True: 0, False: 36]
  ------------------
   86|      0|		return "agent refused operation";
   87|      0|	case SSH_ERR_DH_GEX_OUT_OF_RANGE:
  ------------------
  |  |   52|      0|#define SSH_ERR_DH_GEX_OUT_OF_RANGE		-28
  ------------------
  |  Branch (87:2): [True: 0, False: 36]
  ------------------
   88|      0|		return "DH GEX group out of range";
   89|      0|	case SSH_ERR_DISCONNECTED:
  ------------------
  |  |   53|      0|#define SSH_ERR_DISCONNECTED			-29
  ------------------
  |  Branch (89:2): [True: 0, False: 36]
  ------------------
   90|      0|		return "disconnected";
   91|      0|	case SSH_ERR_MAC_INVALID:
  ------------------
  |  |   54|      0|#define SSH_ERR_MAC_INVALID			-30
  ------------------
  |  Branch (91:2): [True: 0, False: 36]
  ------------------
   92|      0|		return "message authentication code incorrect";
   93|      0|	case SSH_ERR_NO_CIPHER_ALG_MATCH:
  ------------------
  |  |   55|      0|#define SSH_ERR_NO_CIPHER_ALG_MATCH		-31
  ------------------
  |  Branch (93:2): [True: 0, False: 36]
  ------------------
   94|      0|		return "no matching cipher found";
   95|      0|	case SSH_ERR_NO_MAC_ALG_MATCH:
  ------------------
  |  |   56|      0|#define SSH_ERR_NO_MAC_ALG_MATCH		-32
  ------------------
  |  Branch (95:2): [True: 0, False: 36]
  ------------------
   96|      0|		return "no matching MAC found";
   97|      0|	case SSH_ERR_NO_COMPRESS_ALG_MATCH:
  ------------------
  |  |   57|      0|#define SSH_ERR_NO_COMPRESS_ALG_MATCH		-33
  ------------------
  |  Branch (97:2): [True: 0, False: 36]
  ------------------
   98|      0|		return "no matching compression method found";
   99|      0|	case SSH_ERR_NO_KEX_ALG_MATCH:
  ------------------
  |  |   58|      0|#define SSH_ERR_NO_KEX_ALG_MATCH		-34
  ------------------
  |  Branch (99:2): [True: 0, False: 36]
  ------------------
  100|      0|		return "no matching key exchange method found";
  101|      0|	case SSH_ERR_NO_HOSTKEY_ALG_MATCH:
  ------------------
  |  |   59|      0|#define SSH_ERR_NO_HOSTKEY_ALG_MATCH		-35
  ------------------
  |  Branch (101:2): [True: 0, False: 36]
  ------------------
  102|      0|		return "no matching host key type found";
  103|      0|	case SSH_ERR_PROTOCOL_MISMATCH:
  ------------------
  |  |   61|      0|#define SSH_ERR_PROTOCOL_MISMATCH		-37
  ------------------
  |  Branch (103:2): [True: 0, False: 36]
  ------------------
  104|      0|		return "protocol version mismatch";
  105|      0|	case SSH_ERR_NO_PROTOCOL_VERSION:
  ------------------
  |  |   62|      0|#define SSH_ERR_NO_PROTOCOL_VERSION		-38
  ------------------
  |  Branch (105:2): [True: 0, False: 36]
  ------------------
  106|      0|		return "could not read protocol version";
  107|      0|	case SSH_ERR_NO_HOSTKEY_LOADED:
  ------------------
  |  |   60|      0|#define SSH_ERR_NO_HOSTKEY_LOADED		-36
  ------------------
  |  Branch (107:2): [True: 0, False: 36]
  ------------------
  108|      0|		return "could not load host key";
  109|      0|	case SSH_ERR_NEED_REKEY:
  ------------------
  |  |   63|      0|#define SSH_ERR_NEED_REKEY			-39
  ------------------
  |  Branch (109:2): [True: 0, False: 36]
  ------------------
  110|      0|		return "rekeying not supported by peer";
  111|      0|	case SSH_ERR_PASSPHRASE_TOO_SHORT:
  ------------------
  |  |   64|      0|#define SSH_ERR_PASSPHRASE_TOO_SHORT		-40
  ------------------
  |  Branch (111:2): [True: 0, False: 36]
  ------------------
  112|      0|		return "passphrase is too short (minimum five characters)";
  113|      0|	case SSH_ERR_FILE_CHANGED:
  ------------------
  |  |   65|      0|#define SSH_ERR_FILE_CHANGED			-41
  ------------------
  |  Branch (113:2): [True: 0, False: 36]
  ------------------
  114|      0|		return "file changed while reading";
  115|      0|	case SSH_ERR_KEY_UNKNOWN_CIPHER:
  ------------------
  |  |   66|      0|#define SSH_ERR_KEY_UNKNOWN_CIPHER		-42
  ------------------
  |  Branch (115:2): [True: 0, False: 36]
  ------------------
  116|      0|		return "key encrypted using unsupported cipher";
  117|      0|	case SSH_ERR_KEY_WRONG_PASSPHRASE:
  ------------------
  |  |   67|      0|#define SSH_ERR_KEY_WRONG_PASSPHRASE		-43
  ------------------
  |  Branch (117:2): [True: 0, False: 36]
  ------------------
  118|      0|		return "incorrect passphrase supplied to decrypt private key";
  119|      0|	case SSH_ERR_KEY_BAD_PERMISSIONS:
  ------------------
  |  |   68|      0|#define SSH_ERR_KEY_BAD_PERMISSIONS		-44
  ------------------
  |  Branch (119:2): [True: 0, False: 36]
  ------------------
  120|      0|		return "bad permissions";
  121|      0|	case SSH_ERR_KEY_CERT_MISMATCH:
  ------------------
  |  |   69|      0|#define SSH_ERR_KEY_CERT_MISMATCH		-45
  ------------------
  |  Branch (121:2): [True: 0, False: 36]
  ------------------
  122|      0|		return "certificate does not match key";
  123|      0|	case SSH_ERR_KEY_NOT_FOUND:
  ------------------
  |  |   70|      0|#define SSH_ERR_KEY_NOT_FOUND			-46
  ------------------
  |  Branch (123:2): [True: 0, False: 36]
  ------------------
  124|      0|		return "key not found";
  125|      0|	case SSH_ERR_AGENT_NOT_PRESENT:
  ------------------
  |  |   71|      0|#define SSH_ERR_AGENT_NOT_PRESENT		-47
  ------------------
  |  Branch (125:2): [True: 0, False: 36]
  ------------------
  126|      0|		return "agent not present";
  127|      0|	case SSH_ERR_AGENT_NO_IDENTITIES:
  ------------------
  |  |   72|      0|#define SSH_ERR_AGENT_NO_IDENTITIES		-48
  ------------------
  |  Branch (127:2): [True: 0, False: 36]
  ------------------
  128|      0|		return "agent contains no identities";
  129|      0|	case SSH_ERR_BUFFER_READ_ONLY:
  ------------------
  |  |   73|      0|#define SSH_ERR_BUFFER_READ_ONLY		-49
  ------------------
  |  Branch (129:2): [True: 0, False: 36]
  ------------------
  130|      0|		return "internal error: buffer is read-only";
  131|      0|	case SSH_ERR_KRL_BAD_MAGIC:
  ------------------
  |  |   74|      0|#define SSH_ERR_KRL_BAD_MAGIC			-50
  ------------------
  |  Branch (131:2): [True: 0, False: 36]
  ------------------
  132|      0|		return "KRL file has invalid magic number";
  133|      0|	case SSH_ERR_KEY_REVOKED:
  ------------------
  |  |   75|      0|#define SSH_ERR_KEY_REVOKED			-51
  ------------------
  |  Branch (133:2): [True: 0, False: 36]
  ------------------
  134|      0|		return "Key is revoked";
  135|      0|	case SSH_ERR_CONN_CLOSED:
  ------------------
  |  |   76|      0|#define SSH_ERR_CONN_CLOSED			-52
  ------------------
  |  Branch (135:2): [True: 0, False: 36]
  ------------------
  136|      0|		return "Connection closed";
  137|      0|	case SSH_ERR_CONN_TIMEOUT:
  ------------------
  |  |   77|      0|#define SSH_ERR_CONN_TIMEOUT			-53
  ------------------
  |  Branch (137:2): [True: 0, False: 36]
  ------------------
  138|      0|		return "Connection timed out";
  139|      0|	case SSH_ERR_CONN_CORRUPT:
  ------------------
  |  |   78|      0|#define SSH_ERR_CONN_CORRUPT			-54
  ------------------
  |  Branch (139:2): [True: 0, False: 36]
  ------------------
  140|      0|		return "Connection corrupted";
  141|      0|	case SSH_ERR_PROTOCOL_ERROR:
  ------------------
  |  |   79|      0|#define SSH_ERR_PROTOCOL_ERROR			-55
  ------------------
  |  Branch (141:2): [True: 0, False: 36]
  ------------------
  142|      0|		return "Protocol error";
  143|      0|	case SSH_ERR_KEY_LENGTH:
  ------------------
  |  |   80|      0|#define SSH_ERR_KEY_LENGTH			-56
  ------------------
  |  Branch (143:2): [True: 0, False: 36]
  ------------------
  144|      0|		return "Invalid key length";
  145|      0|	case SSH_ERR_NUMBER_TOO_LARGE:
  ------------------
  |  |   81|      0|#define SSH_ERR_NUMBER_TOO_LARGE		-57
  ------------------
  |  Branch (145:2): [True: 0, False: 36]
  ------------------
  146|      0|		return "number is too large";
  147|      0|	case SSH_ERR_KEY_ALG_UNSUPPORTED:
  ------------------
  |  |   87|      0|#define SSH_ERR_KEY_ALG_UNSUPPORTED		-63
  ------------------
  |  Branch (147:2): [True: 0, False: 36]
  ------------------
  148|      0|		return "key algorithm not supported";
  149|      0|	case SSH_ERR_SIGN_ALG_UNSUPPORTED:
  ------------------
  |  |   82|      0|#define SSH_ERR_SIGN_ALG_UNSUPPORTED		-58
  ------------------
  |  Branch (149:2): [True: 0, False: 36]
  ------------------
  150|      0|		return "signature algorithm not supported";
  151|      0|	case SSH_ERR_FEATURE_UNSUPPORTED:
  ------------------
  |  |   83|      0|#define SSH_ERR_FEATURE_UNSUPPORTED		-59
  ------------------
  |  Branch (151:2): [True: 0, False: 36]
  ------------------
  152|      0|		return "requested feature not supported";
  153|      0|	case SSH_ERR_DEVICE_NOT_FOUND:
  ------------------
  |  |   84|      0|#define SSH_ERR_DEVICE_NOT_FOUND		-60
  ------------------
  |  Branch (153:2): [True: 0, False: 36]
  ------------------
  154|      0|		return "device not found";
  155|      0|	default:
  ------------------
  |  Branch (155:2): [True: 0, False: 36]
  ------------------
  156|      0|		return "unknown error";
  157|     36|	}
  158|     36|}

sshkey_type:
  189|      4|{
  190|      4|	const struct sshkey_impl *impl;
  191|       |
  192|      4|	if ((impl = sshkey_impl_from_key(k)) == NULL)
  ------------------
  |  Branch (192:6): [True: 0, False: 4]
  ------------------
  193|      0|		return "unknown";
  194|      4|	return impl->shortname;
  195|      4|}
sshkey_type_is_cert:
  209|     20|{
  210|     20|	const struct sshkey_impl *impl;
  211|       |
  212|     20|	if ((impl = sshkey_impl_from_type(type)) == NULL)
  ------------------
  |  Branch (212:6): [True: 2, False: 18]
  ------------------
  213|      2|		return 0;
  214|     18|	return impl->cert;
  215|     20|}
sshkey_ssh_name:
  219|      1|{
  220|      1|	return sshkey_ssh_name_from_type_nid(k->type, k->ecdsa_nid);
  221|      1|}
sshkey_type_from_name:
  250|     11|{
  251|     11|	return type_from_name(name, 0);
  252|     11|}
sshkey_ecdsa_nid_from_name:
  275|      4|{
  276|      4|	int i;
  277|       |
  278|     92|	for (i = 0; keyimpls[i] != NULL; i++) {
  ------------------
  |  Branch (278:14): [True: 88, False: 4]
  ------------------
  279|     88|		if (!key_type_is_ecdsa_variant(keyimpls[i]->type))
  ------------------
  |  Branch (279:7): [True: 48, False: 40]
  ------------------
  280|     48|			continue;
  281|     40|		if (keyimpls[i]->name != NULL &&
  ------------------
  |  Branch (281:7): [True: 40, False: 0]
  ------------------
  282|     40|		    strcmp(name, keyimpls[i]->name) == 0)
  ------------------
  |  Branch (282:7): [True: 0, False: 40]
  ------------------
  283|      0|			return keyimpls[i]->nid;
  284|     40|	}
  285|      4|	return -1;
  286|      4|}
sshkey_match_keyname_to_sigalgs:
  290|      1|{
  291|      1|	int ktype;
  292|       |
  293|      1|	if (sigalgs == NULL || *sigalgs == '\0' ||
  ------------------
  |  Branch (293:6): [True: 0, False: 1]
  |  Branch (293:25): [True: 0, False: 1]
  ------------------
  294|      1|	    (ktype = sshkey_type_from_name(keyname)) == KEY_UNSPEC)
  ------------------
  |  Branch (294:6): [True: 0, False: 1]
  ------------------
  295|      0|		return 0;
  296|      1|	else if (ktype == KEY_RSA) {
  ------------------
  |  Branch (296:11): [True: 0, False: 1]
  ------------------
  297|      0|		return match_pattern_list("ssh-rsa", sigalgs, 0) == 1 ||
  ------------------
  |  Branch (297:10): [True: 0, False: 0]
  ------------------
  298|      0|		    match_pattern_list("rsa-sha2-256", sigalgs, 0) == 1 ||
  ------------------
  |  Branch (298:7): [True: 0, False: 0]
  ------------------
  299|      0|		    match_pattern_list("rsa-sha2-512", sigalgs, 0) == 1;
  ------------------
  |  Branch (299:7): [True: 0, False: 0]
  ------------------
  300|      1|	} else if (ktype == KEY_RSA_CERT) {
  ------------------
  |  Branch (300:13): [True: 0, False: 1]
  ------------------
  301|      0|		return match_pattern_list("ssh-rsa-cert-v01@openssh.com",
  ------------------
  |  Branch (301:10): [True: 0, False: 0]
  ------------------
  302|      0|		    sigalgs, 0) == 1 ||
  303|      0|		    match_pattern_list("rsa-sha2-256-cert-v01@openssh.com",
  ------------------
  |  Branch (303:7): [True: 0, False: 0]
  ------------------
  304|      0|		    sigalgs, 0) == 1 ||
  305|      0|		    match_pattern_list("rsa-sha2-512-cert-v01@openssh.com",
  ------------------
  |  Branch (305:7): [True: 0, False: 0]
  ------------------
  306|      0|		    sigalgs, 0) == 1;
  307|      1|	} else if (ktype == KEY_ECDSA_SK) {
  ------------------
  |  Branch (307:13): [True: 0, False: 1]
  ------------------
  308|      0|		return match_pattern_list("sk-ecdsa-sha2-nistp256@openssh.com",
  ------------------
  |  Branch (308:10): [True: 0, False: 0]
  ------------------
  309|      0|		    sigalgs, 0) == 1 || match_pattern_list(
  ------------------
  |  Branch (309:27): [True: 0, False: 0]
  ------------------
  310|      0|		    "webauthn-sk-ecdsa-sha2-nistp256@openssh.com",
  311|      0|		    sigalgs, 0) == 1;
  312|      1|	} else if (ktype == KEY_ECDSA_SK_CERT) {
  ------------------
  |  Branch (312:13): [True: 0, False: 1]
  ------------------
  313|      0|		return match_pattern_list(
  ------------------
  |  Branch (313:10): [True: 0, False: 0]
  ------------------
  314|      0|		    "sk-ecdsa-sha2-nistp256-cert-v01@openssh.com",
  315|      0|		    sigalgs, 0) == 1 || match_pattern_list(
  ------------------
  |  Branch (315:27): [True: 0, False: 0]
  ------------------
  316|      0|		    "webauthn-sk-ecdsa-sha2-nistp256-cert-v01@openssh.com",
  317|      0|		    sigalgs, 0) == 1;
  318|      0|	} else
  319|      1|		return match_pattern_list(keyname, sigalgs, 0) == 1;
  320|      1|}
sshkey_alg_list:
  324|      3|{
  325|      3|	char *ret = NULL;
  326|      3|	size_t i;
  327|      3|	const struct sshkey_impl *impl;
  328|      3|	char sep_str[2] = {sep, '\0'};
  329|       |
  330|     69|	for (i = 0; keyimpls[i] != NULL; i++) {
  ------------------
  |  Branch (330:14): [True: 66, False: 3]
  ------------------
  331|     66|		impl = keyimpls[i];
  332|     66|		if (impl->name == NULL)
  ------------------
  |  Branch (332:7): [True: 0, False: 66]
  ------------------
  333|      0|			continue;
  334|     66|		if (!include_sigonly && impl->sigonly)
  ------------------
  |  Branch (334:7): [True: 0, False: 66]
  |  Branch (334:27): [True: 0, False: 0]
  ------------------
  335|      0|			continue;
  336|     66|		if ((certs_only && !impl->cert) || (plain_only && impl->cert))
  ------------------
  |  Branch (336:8): [True: 0, False: 66]
  |  Branch (336:22): [True: 0, False: 0]
  |  Branch (336:39): [True: 44, False: 22]
  |  Branch (336:53): [True: 22, False: 22]
  ------------------
  337|     22|			continue;
  338|     44|		xextendf(&ret, sep_str, "%s", impl->name);
  339|     44|	}
  340|      3|	return ret;
  341|      3|}
sshkey_is_cert:
  411|     15|{
  412|     15|	if (k == NULL)
  ------------------
  |  Branch (412:6): [True: 0, False: 15]
  ------------------
  413|      0|		return 0;
  414|     15|	return sshkey_type_is_cert(k->type);
  415|     15|}
sshkey_is_sk:
  419|      1|{
  420|      1|	if (k == NULL)
  ------------------
  |  Branch (420:6): [True: 0, False: 1]
  ------------------
  421|      0|		return 0;
  422|      1|	switch (sshkey_type_plain(k->type)) {
  423|      0|	case KEY_ECDSA_SK:
  ------------------
  |  Branch (423:2): [True: 0, False: 1]
  ------------------
  424|      0|	case KEY_ED25519_SK:
  ------------------
  |  Branch (424:2): [True: 0, False: 1]
  ------------------
  425|      0|		return 1;
  426|      1|	default:
  ------------------
  |  Branch (426:2): [True: 1, False: 0]
  ------------------
  427|      1|		return 0;
  428|      1|	}
  429|      1|}
sshkey_type_plain:
  434|      9|{
  435|      9|	switch (type) {
  436|      0|	case KEY_RSA_CERT:
  ------------------
  |  Branch (436:2): [True: 0, False: 9]
  ------------------
  437|      0|		return KEY_RSA;
  438|      0|	case KEY_ECDSA_CERT:
  ------------------
  |  Branch (438:2): [True: 0, False: 9]
  ------------------
  439|      0|		return KEY_ECDSA;
  440|      0|	case KEY_ECDSA_SK_CERT:
  ------------------
  |  Branch (440:2): [True: 0, False: 9]
  ------------------
  441|      0|		return KEY_ECDSA_SK;
  442|      0|	case KEY_ED25519_CERT:
  ------------------
  |  Branch (442:2): [True: 0, False: 9]
  ------------------
  443|      0|		return KEY_ED25519;
  444|      0|	case KEY_MLDSA44_ED25519_CERT:
  ------------------
  |  Branch (444:2): [True: 0, False: 9]
  ------------------
  445|      0|		return KEY_MLDSA44_ED25519;
  446|      0|	case KEY_ED25519_SK_CERT:
  ------------------
  |  Branch (446:2): [True: 0, False: 9]
  ------------------
  447|      0|		return KEY_ED25519_SK;
  448|      9|	default:
  ------------------
  |  Branch (448:2): [True: 9, False: 0]
  ------------------
  449|      9|		return type;
  450|      9|	}
  451|      9|}
sshkey_new:
  686|      7|{
  687|      7|	struct sshkey *k;
  688|      7|	const struct sshkey_impl *impl = NULL;
  689|       |
  690|      7|	if (type != KEY_UNSPEC &&
  ------------------
  |  Branch (690:6): [True: 6, False: 1]
  ------------------
  691|      6|	    (impl = sshkey_impl_from_type(type)) == NULL)
  ------------------
  |  Branch (691:6): [True: 0, False: 6]
  ------------------
  692|      0|		return NULL;
  693|       |
  694|       |	/* All non-certificate types may act as CAs */
  695|      7|	if ((k = calloc(1, sizeof(*k))) == NULL)
  ------------------
  |  Branch (695:6): [True: 0, False: 7]
  ------------------
  696|      0|		return NULL;
  697|      7|	k->type = type;
  698|      7|	k->ecdsa_nid = -1;
  699|      7|	if (impl != NULL && impl->funcs->alloc != NULL) {
  ------------------
  |  Branch (699:6): [True: 6, False: 1]
  |  Branch (699:22): [True: 0, False: 6]
  ------------------
  700|      0|		if (impl->funcs->alloc(k) != 0) {
  ------------------
  |  Branch (700:7): [True: 0, False: 0]
  ------------------
  701|      0|			free(k);
  702|      0|			return NULL;
  703|      0|		}
  704|      0|	}
  705|      7|	if (sshkey_is_cert(k)) {
  ------------------
  |  Branch (705:6): [True: 0, False: 7]
  ------------------
  706|      0|		if ((k->cert = cert_new()) == NULL) {
  ------------------
  |  Branch (706:7): [True: 0, False: 0]
  ------------------
  707|      0|			sshkey_free(k);
  708|      0|			return NULL;
  709|      0|		}
  710|      0|	}
  711|       |
  712|      7|	return k;
  713|      7|}
sshkey_free:
  786|    859|{
  787|    859|	sshkey_free_contents(k);
  788|    859|	freezero(k, sizeof(*k));
  789|    859|}
sshkey_equal_public:
  823|      2|{
  824|      2|	const struct sshkey_impl *impl;
  825|       |
  826|      2|	if (a == NULL || b == NULL ||
  ------------------
  |  Branch (826:6): [True: 0, False: 2]
  |  Branch (826:19): [True: 0, False: 2]
  ------------------
  827|      2|	    sshkey_type_plain(a->type) != sshkey_type_plain(b->type))
  ------------------
  |  Branch (827:6): [True: 0, False: 2]
  ------------------
  828|      0|		return 0;
  829|      2|	if ((impl = sshkey_impl_from_type(a->type)) == NULL)
  ------------------
  |  Branch (829:6): [True: 0, False: 2]
  ------------------
  830|      0|		return 0;
  831|      2|	return impl->funcs->equal(a, b);
  832|      2|}
sshkey_equal:
  836|      1|{
  837|      1|	if (a == NULL || b == NULL || a->type != b->type)
  ------------------
  |  Branch (837:6): [True: 0, False: 1]
  |  Branch (837:19): [True: 0, False: 1]
  |  Branch (837:32): [True: 0, False: 1]
  ------------------
  838|      0|		return 0;
  839|      1|	if (sshkey_is_cert(a)) {
  ------------------
  |  Branch (839:6): [True: 0, False: 1]
  ------------------
  840|      0|		if (!cert_compare(a->cert, b->cert))
  ------------------
  |  Branch (840:7): [True: 0, False: 0]
  ------------------
  841|      0|			return 0;
  842|      0|	}
  843|      1|	return sshkey_equal_public(a, b);
  844|      1|}
sshkey_putb:
  893|      1|{
  894|      1|	return to_blob_buf(key, b, 0, SSHKEY_SERIALIZE_DEFAULT);
  895|      1|}
sshkey_read:
 1300|      1|{
 1301|      1|	struct sshkey *k;
 1302|      1|	char *cp, *blobcopy;
 1303|      1|	size_t space;
 1304|      1|	int r, type, curve_nid = -1;
 1305|      1|	struct sshbuf *blob;
 1306|       |
 1307|      1|	if (ret == NULL)
  ------------------
  |  Branch (1307:6): [True: 0, False: 1]
  ------------------
 1308|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
 1309|      1|	if (ret->type != KEY_UNSPEC && sshkey_impl_from_type(ret->type) == NULL)
  ------------------
  |  Branch (1309:6): [True: 0, False: 1]
  |  Branch (1309:33): [True: 0, False: 0]
  ------------------
 1310|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
 1311|       |
 1312|       |	/* Decode type */
 1313|      1|	cp = *cpp;
 1314|      1|	space = strcspn(cp, " \t");
 1315|      1|	if (space == strlen(cp))
  ------------------
  |  Branch (1315:6): [True: 0, False: 1]
  ------------------
 1316|      0|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1317|      1|	if ((type = peek_type_nid(cp, space, &curve_nid)) == KEY_UNSPEC)
  ------------------
  |  Branch (1317:6): [True: 0, False: 1]
  ------------------
 1318|      0|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1319|       |
 1320|       |	/* skip whitespace */
 1321|      2|	for (cp += space; *cp == ' ' || *cp == '\t'; cp++)
  ------------------
  |  Branch (1321:20): [True: 1, False: 1]
  |  Branch (1321:34): [True: 0, False: 1]
  ------------------
 1322|      1|		;
 1323|      1|	if (*cp == '\0')
  ------------------
  |  Branch (1323:6): [True: 0, False: 1]
  ------------------
 1324|      0|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1325|      1|	if (ret->type != KEY_UNSPEC && ret->type != type)
  ------------------
  |  Branch (1325:6): [True: 0, False: 1]
  |  Branch (1325:33): [True: 0, False: 0]
  ------------------
 1326|      0|		return SSH_ERR_KEY_TYPE_MISMATCH;
  ------------------
  |  |   37|      0|#define SSH_ERR_KEY_TYPE_MISMATCH		-13
  ------------------
 1327|      1|	if ((blob = sshbuf_new()) == NULL)
  ------------------
  |  Branch (1327:6): [True: 0, False: 1]
  ------------------
 1328|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 1329|       |
 1330|       |	/* find end of keyblob and decode */
 1331|      1|	space = strcspn(cp, " \t");
 1332|      1|	if ((blobcopy = strndup(cp, space)) == NULL) {
  ------------------
  |  Branch (1332:6): [True: 0, False: 1]
  ------------------
 1333|      0|		sshbuf_free(blob);
 1334|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 1335|      0|	}
 1336|      1|	if ((r = sshbuf_b64tod(blob, blobcopy)) != 0) {
  ------------------
  |  Branch (1336:6): [True: 0, False: 1]
  ------------------
 1337|      0|		free(blobcopy);
 1338|      0|		sshbuf_free(blob);
 1339|      0|		return r;
 1340|      0|	}
 1341|      1|	free(blobcopy);
 1342|      1|	if ((r = sshkey_fromb(blob, &k)) != 0) {
  ------------------
  |  Branch (1342:6): [True: 0, False: 1]
  ------------------
 1343|      0|		sshbuf_free(blob);
 1344|      0|		return r;
 1345|      0|	}
 1346|      1|	sshbuf_free(blob);
 1347|       |
 1348|       |	/* skip whitespace and leave cp at start of comment */
 1349|      1|	for (cp += space; *cp == ' ' || *cp == '\t'; cp++)
  ------------------
  |  Branch (1349:20): [True: 0, False: 1]
  |  Branch (1349:34): [True: 0, False: 1]
  ------------------
 1350|      0|		;
 1351|       |
 1352|       |	/* ensure type of blob matches type at start of line */
 1353|      1|	if (k->type != type) {
  ------------------
  |  Branch (1353:6): [True: 0, False: 1]
  ------------------
 1354|      0|		sshkey_free(k);
 1355|      0|		return SSH_ERR_KEY_TYPE_MISMATCH;
  ------------------
  |  |   37|      0|#define SSH_ERR_KEY_TYPE_MISMATCH		-13
  ------------------
 1356|      0|	}
 1357|      1|	if (key_type_is_ecdsa_variant(type) && curve_nid != k->ecdsa_nid) {
  ------------------
  |  Branch (1357:6): [True: 0, False: 1]
  |  Branch (1357:41): [True: 0, False: 0]
  ------------------
 1358|      0|		sshkey_free(k);
 1359|      0|		return SSH_ERR_EC_CURVE_MISMATCH;
  ------------------
  |  |   39|      0|#define SSH_ERR_EC_CURVE_MISMATCH		-15
  ------------------
 1360|      0|	}
 1361|       |
 1362|       |	/* Fill in ret from parsed key */
 1363|      1|	sshkey_free_contents(ret);
 1364|      1|	*ret = *k;
 1365|      1|	freezero(k, sizeof(*k));
 1366|       |
 1367|       |	/* success */
 1368|      1|	*cpp = cp;
 1369|      1|	return 0;
 1370|      1|}
sshkey_from_private:
 1599|      2|{
 1600|      2|	struct sshkey *n = NULL;
 1601|      2|	int r = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      2|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 1602|      2|	const struct sshkey_impl *impl;
 1603|       |
 1604|      2|	*pkp = NULL;
 1605|      2|	if ((impl = sshkey_impl_from_key(k)) == NULL)
  ------------------
  |  Branch (1605:6): [True: 0, False: 2]
  ------------------
 1606|      0|		return SSH_ERR_KEY_TYPE_UNKNOWN;
  ------------------
  |  |   38|      0|#define SSH_ERR_KEY_TYPE_UNKNOWN		-14 /* XXX UNSUPPORTED? */
  ------------------
 1607|      2|	if ((n = sshkey_new(k->type)) == NULL) {
  ------------------
  |  Branch (1607:6): [True: 0, False: 2]
  ------------------
 1608|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 1609|      0|		goto out;
 1610|      0|	}
 1611|      2|	if ((r = impl->funcs->copy_public(k, n)) != 0)
  ------------------
  |  Branch (1611:6): [True: 0, False: 2]
  ------------------
 1612|      0|		goto out;
 1613|      2|	if (sshkey_is_cert(k) && (r = sshkey_cert_copy(k, n)) != 0)
  ------------------
  |  Branch (1613:6): [True: 0, False: 2]
  |  Branch (1613:27): [True: 0, False: 0]
  ------------------
 1614|      0|		goto out;
 1615|       |	/* success */
 1616|      2|	*pkp = n;
 1617|      2|	n = NULL;
 1618|      2|	r = 0;
 1619|      2| out:
 1620|      2|	sshkey_free(n);
 1621|      2|	return r;
 1622|      2|}
sshkey_is_shielded:
 1626|      2|{
 1627|      2|	return k != NULL && k->shielded_private != NULL;
  ------------------
  |  Branch (1627:9): [True: 2, False: 0]
  |  Branch (1627:22): [True: 0, False: 2]
  ------------------
 1628|      2|}
sshkey_unshield_private:
 1766|      1|{
 1767|      1|	struct sshbuf *prvbuf = NULL;
 1768|      1|	u_char *cp, keyiv[SSH_DIGEST_MAX_LENGTH];
 1769|      1|	struct sshcipher_ctx *cctx = NULL;
 1770|      1|	const struct sshcipher *cipher;
 1771|      1|	struct sshkey *kswap = NULL, tmp;
 1772|      1|	int r = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      1|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 1773|       |
 1774|       |#ifdef DEBUG_PK
 1775|       |	fprintf(stderr, "%s: entering for %s\n", __func__, sshkey_ssh_name(k));
 1776|       |#endif
 1777|      1|	if (!sshkey_is_shielded(k))
  ------------------
  |  Branch (1777:6): [True: 1, False: 0]
  ------------------
 1778|      1|		return 0; /* nothing to do */
 1779|       |
 1780|      0|	if ((cipher = cipher_by_name(SSHKEY_SHIELD_CIPHER)) == NULL) {
  ------------------
  |  |   83|      0|#define SSHKEY_SHIELD_CIPHER		"aes256-ctr" /* XXX want AES-EME* */
  ------------------
  |  Branch (1780:6): [True: 0, False: 0]
  ------------------
 1781|      0|		r = SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
 1782|      0|		goto out;
 1783|      0|	}
 1784|      0|	if (cipher_keylen(cipher) + cipher_ivlen(cipher) >
  ------------------
  |  Branch (1784:6): [True: 0, False: 0]
  ------------------
 1785|      0|	    ssh_digest_bytes(SSHKEY_SHIELD_PREKEY_HASH)) {
  ------------------
  |  |   84|      0|#define SSHKEY_SHIELD_PREKEY_HASH	SSH_DIGEST_SHA512
  |  |  ------------------
  |  |  |  |   29|      0|#define SSH_DIGEST_SHA512	4
  |  |  ------------------
  ------------------
 1786|      0|		r = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 1787|      0|		goto out;
 1788|      0|	}
 1789|       |	/* check size of shielded key blob */
 1790|      0|	if (k->shielded_len < cipher_blocksize(cipher) ||
  ------------------
  |  Branch (1790:6): [True: 0, False: 0]
  ------------------
 1791|      0|	    (k->shielded_len % cipher_blocksize(cipher)) != 0) {
  ------------------
  |  Branch (1791:6): [True: 0, False: 0]
  ------------------
 1792|      0|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1793|      0|		goto out;
 1794|      0|	}
 1795|       |
 1796|       |	/* Calculate the ephemeral key from the prekey */
 1797|      0|	if ((r = ssh_digest_memory(SSHKEY_SHIELD_PREKEY_HASH,
  ------------------
  |  |   84|      0|#define SSHKEY_SHIELD_PREKEY_HASH	SSH_DIGEST_SHA512
  |  |  ------------------
  |  |  |  |   29|      0|#define SSH_DIGEST_SHA512	4
  |  |  ------------------
  ------------------
  |  Branch (1797:6): [True: 0, False: 0]
  ------------------
 1798|      0|	    k->shield_prekey, k->shield_prekey_len,
 1799|      0|	    keyiv, SSH_DIGEST_MAX_LENGTH)) != 0)
  ------------------
  |  |   22|      0|#define SSH_DIGEST_MAX_LENGTH	64
  ------------------
 1800|      0|		goto out;
 1801|      0|	if ((r = cipher_init(&cctx, cipher, keyiv, cipher_keylen(cipher),
  ------------------
  |  Branch (1801:6): [True: 0, False: 0]
  ------------------
 1802|      0|	    keyiv + cipher_keylen(cipher), cipher_ivlen(cipher), 0)) != 0)
 1803|      0|		goto out;
 1804|       |#ifdef DEBUG_PK
 1805|       |	fprintf(stderr, "%s: key+iv\n", __func__);
 1806|       |	sshbuf_dump_data(keyiv, ssh_digest_bytes(SSHKEY_SHIELD_PREKEY_HASH),
 1807|       |	    stderr);
 1808|       |#endif
 1809|       |
 1810|       |	/* Decrypt and parse the shielded private key using the ephemeral key */
 1811|      0|	if ((prvbuf = sshbuf_new()) == NULL) {
  ------------------
  |  Branch (1811:6): [True: 0, False: 0]
  ------------------
 1812|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 1813|      0|		goto out;
 1814|      0|	}
 1815|      0|	if ((r = sshbuf_reserve(prvbuf, k->shielded_len, &cp)) != 0)
  ------------------
  |  Branch (1815:6): [True: 0, False: 0]
  ------------------
 1816|      0|		goto out;
 1817|       |	/* decrypt */
 1818|       |#ifdef DEBUG_PK
 1819|       |	fprintf(stderr, "%s: encrypted\n", __func__);
 1820|       |	sshbuf_dump_data(k->shielded_private, k->shielded_len, stderr);
 1821|       |#endif
 1822|      0|	if ((r = cipher_crypt(cctx, 0, cp,
  ------------------
  |  Branch (1822:6): [True: 0, False: 0]
  ------------------
 1823|      0|	    k->shielded_private, k->shielded_len, 0, 0)) != 0)
 1824|      0|		goto out;
 1825|       |#ifdef DEBUG_PK
 1826|       |	fprintf(stderr, "%s: serialised\n", __func__);
 1827|       |	sshbuf_dump(prvbuf, stderr);
 1828|       |#endif
 1829|       |	/* Parse private key */
 1830|      0|	if ((r = sshkey_private_deserialize(prvbuf, &kswap)) != 0)
  ------------------
  |  Branch (1830:6): [True: 0, False: 0]
  ------------------
 1831|      0|		goto out;
 1832|       |
 1833|      0|	if ((r = private2_check_padding(prvbuf)) != 0)
  ------------------
  |  Branch (1833:6): [True: 0, False: 0]
  ------------------
 1834|      0|		goto out;
 1835|       |
 1836|       |	/* Swap the parsed key back into place */
 1837|      0|	tmp = *kswap;
 1838|      0|	*kswap = *k;
 1839|      0|	*k = tmp;
 1840|       |
 1841|       |	/* success */
 1842|      0|	r = 0;
 1843|       |
 1844|      0| out:
 1845|      0|	cipher_free(cctx);
 1846|      0|	explicit_bzero(keyiv, sizeof(keyiv));
 1847|      0|	explicit_bzero(&tmp, sizeof(tmp));
 1848|      0|	sshkey_free(kswap);
 1849|      0|	sshbuf_free(prvbuf);
 1850|      0|	return r;
 1851|      0|}
sshkey_fromb:
 2094|      1|{
 2095|      1|	return sshkey_from_blob_internal(b, keyp, 1, NULL, NULL);
 2096|      1|}
sshkey_fromb_allowlist:
 2101|      1|{
 2102|      1|	return sshkey_from_blob_internal(b, keyp, 1,
 2103|      1|	    alg_allowlist, ca_sigalg_allowlist);
 2104|      1|}
sshkey_froms:
 2108|      1|{
 2109|      1|	struct sshbuf *b;
 2110|      1|	int r;
 2111|       |
 2112|      1|	if ((r = sshbuf_froms(buf, &b)) != 0)
  ------------------
  |  Branch (2112:6): [True: 0, False: 1]
  ------------------
 2113|      0|		return r;
 2114|      1|	r = sshkey_from_blob_internal(b, keyp, 1, NULL, NULL);
 2115|      1|	sshbuf_free(b);
 2116|      1|	return r;
 2117|      1|}
sshkey_sign:
 2216|      1|{
 2217|      1|	int was_shielded = sshkey_is_shielded(key);
 2218|      1|	int r2, r = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      1|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 2219|      1|	const struct sshkey_impl *impl;
 2220|       |
 2221|      1|	if (sigp != NULL)
  ------------------
  |  Branch (2221:6): [True: 1, False: 0]
  ------------------
 2222|      1|		*sigp = NULL;
 2223|      1|	if (lenp != NULL)
  ------------------
  |  Branch (2223:6): [True: 1, False: 0]
  ------------------
 2224|      1|		*lenp = 0;
 2225|      1|	if (datalen > SSH_KEY_MAX_SIGN_DATA_SIZE)
  ------------------
  |  |   48|      1|#define SSH_KEY_MAX_SIGN_DATA_SIZE	(1 << 20)
  ------------------
  |  Branch (2225:6): [True: 0, False: 1]
  ------------------
 2226|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
 2227|      1|	if ((impl = sshkey_impl_from_key(key)) == NULL)
  ------------------
  |  Branch (2227:6): [True: 0, False: 1]
  ------------------
 2228|      0|		return SSH_ERR_KEY_TYPE_UNKNOWN;
  ------------------
  |  |   38|      0|#define SSH_ERR_KEY_TYPE_UNKNOWN		-14 /* XXX UNSUPPORTED? */
  ------------------
 2229|      1|	if ((r = sshkey_unshield_private(key)) != 0)
  ------------------
  |  Branch (2229:6): [True: 0, False: 1]
  ------------------
 2230|      0|		return r;
 2231|      1|	if (sshkey_is_sk(key)) {
  ------------------
  |  Branch (2231:6): [True: 0, False: 1]
  ------------------
 2232|      0|		r = sshsk_sign(sk_provider, key, sigp, lenp, data,
 2233|      0|		    datalen, compat, sk_pin);
 2234|      1|	} else if ((key->flags & SSHKEY_FLAG_EXT) != 0) {
  ------------------
  |  |   94|      1|#define SSHKEY_FLAG_EXT		0x0001
  ------------------
  |  Branch (2234:13): [True: 0, False: 1]
  ------------------
 2235|      0|		r = pkcs11_sign(key, sigp, lenp, data, datalen,
 2236|      0|		    alg, sk_provider, sk_pin, compat);
 2237|      1|	} else {
 2238|      1|		if (impl->funcs->sign == NULL)
  ------------------
  |  Branch (2238:7): [True: 0, False: 1]
  ------------------
 2239|      0|			r = SSH_ERR_SIGN_ALG_UNSUPPORTED;
  ------------------
  |  |   82|      0|#define SSH_ERR_SIGN_ALG_UNSUPPORTED		-58
  ------------------
 2240|      1|		else {
 2241|      1|			r = impl->funcs->sign(key, sigp, lenp, data, datalen,
 2242|      1|			    alg, sk_provider, sk_pin, compat);
 2243|      1|		 }
 2244|      1|	}
 2245|      1|	if (was_shielded && (r2 = sshkey_shield_private(key)) != 0)
  ------------------
  |  Branch (2245:6): [True: 0, False: 1]
  |  Branch (2245:22): [True: 0, False: 0]
  ------------------
 2246|      0|		return r2;
 2247|      1|	return r;
 2248|      1|}
sshkey_verify:
 2259|      1|{
 2260|      1|	const struct sshkey_impl *impl;
 2261|       |
 2262|      1|	if (detailsp != NULL)
  ------------------
  |  Branch (2262:6): [True: 0, False: 1]
  ------------------
 2263|      0|		*detailsp = NULL;
 2264|      1|	if (siglen == 0 || dlen > SSH_KEY_MAX_SIGN_DATA_SIZE)
  ------------------
  |  |   48|      1|#define SSH_KEY_MAX_SIGN_DATA_SIZE	(1 << 20)
  ------------------
  |  Branch (2264:6): [True: 0, False: 1]
  |  Branch (2264:21): [True: 0, False: 1]
  ------------------
 2265|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
 2266|      1|	if ((impl = sshkey_impl_from_key(key)) == NULL)
  ------------------
  |  Branch (2266:6): [True: 0, False: 1]
  ------------------
 2267|      0|		return SSH_ERR_KEY_TYPE_UNKNOWN;
  ------------------
  |  |   38|      0|#define SSH_ERR_KEY_TYPE_UNKNOWN		-14 /* XXX UNSUPPORTED? */
  ------------------
 2268|      1|	return impl->funcs->verify(key, sig, siglen, data, dlen,
 2269|      1|	    alg, compat, detailsp);
 2270|      1|}
sshkey_private_deserialize:
 2637|      1|{
 2638|      1|	const struct sshkey_impl *impl;
 2639|      1|	char *tname = NULL;
 2640|      1|	char *expect_sk_application = NULL;
 2641|      1|	u_char *expect_ed25519_pk = NULL;
 2642|      1|	struct sshkey *k = NULL;
 2643|      1|	int type, r = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      1|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 2644|       |
 2645|      1|	if (kp != NULL)
  ------------------
  |  Branch (2645:6): [True: 1, False: 0]
  ------------------
 2646|      1|		*kp = NULL;
 2647|      1|	if ((r = sshbuf_get_cstring(buf, &tname, NULL)) != 0)
  ------------------
  |  Branch (2647:6): [True: 0, False: 1]
  ------------------
 2648|      0|		goto out;
 2649|      1|	type = sshkey_type_from_name(tname);
 2650|      1|	if (sshkey_type_is_cert(type)) {
  ------------------
  |  Branch (2650:6): [True: 0, False: 1]
  ------------------
 2651|       |		/*
 2652|       |		 * Certificate key private keys begin with the certificate
 2653|       |		 * itself. Make sure this matches the type of the enclosing
 2654|       |		 * private key.
 2655|       |		 */
 2656|      0|		if ((r = sshkey_froms(buf, &k)) != 0)
  ------------------
  |  Branch (2656:7): [True: 0, False: 0]
  ------------------
 2657|      0|			goto out;
 2658|      0|		if (k->type != type) {
  ------------------
  |  Branch (2658:7): [True: 0, False: 0]
  ------------------
 2659|      0|			r = SSH_ERR_KEY_CERT_MISMATCH;
  ------------------
  |  |   69|      0|#define SSH_ERR_KEY_CERT_MISMATCH		-45
  ------------------
 2660|      0|			goto out;
 2661|      0|		}
 2662|       |		/* For ECDSA keys, the group must match too */
 2663|      0|		if (k->type == KEY_ECDSA &&
  ------------------
  |  Branch (2663:7): [True: 0, False: 0]
  ------------------
 2664|      0|		    k->ecdsa_nid != sshkey_ecdsa_nid_from_name(tname)) {
  ------------------
  |  Branch (2664:7): [True: 0, False: 0]
  ------------------
 2665|      0|			r = SSH_ERR_KEY_CERT_MISMATCH;
  ------------------
  |  |   69|      0|#define SSH_ERR_KEY_CERT_MISMATCH		-45
  ------------------
 2666|      0|			goto out;
 2667|      0|		}
 2668|       |		/*
 2669|       |		 * Several fields are redundant between certificate and
 2670|       |		 * private key body, we require these to match.
 2671|       |		 */
 2672|      0|		expect_sk_application = k->sk_application;
 2673|      0|		expect_ed25519_pk = k->ed25519_pk;
 2674|      0|		k->sk_application = NULL;
 2675|      0|		k->ed25519_pk = NULL;
 2676|      1|	} else {
 2677|      1|		if ((k = sshkey_new(type)) == NULL) {
  ------------------
  |  Branch (2677:7): [True: 0, False: 1]
  ------------------
 2678|      0|			r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 2679|      0|			goto out;
 2680|      0|		}
 2681|      1|	}
 2682|      1|	if ((impl = sshkey_impl_from_type(type)) == NULL) {
  ------------------
  |  Branch (2682:6): [True: 0, False: 1]
  ------------------
 2683|      0|		r = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 2684|      0|		goto out;
 2685|      0|	}
 2686|      1|	if ((r = impl->funcs->deserialize_private(tname, buf, k)) != 0)
  ------------------
  |  Branch (2686:6): [True: 0, False: 1]
  ------------------
 2687|      0|		goto out;
 2688|       |
 2689|      1|	if ((expect_sk_application != NULL && (k->sk_application == NULL ||
  ------------------
  |  Branch (2689:7): [True: 0, False: 1]
  |  Branch (2689:41): [True: 0, False: 0]
  ------------------
 2690|      0|	    strcmp(expect_sk_application, k->sk_application) != 0)) ||
  ------------------
  |  Branch (2690:6): [True: 0, False: 0]
  ------------------
 2691|      1|	    (expect_ed25519_pk != NULL && (k->ed25519_pk == NULL ||
  ------------------
  |  Branch (2691:7): [True: 0, False: 1]
  |  Branch (2691:37): [True: 0, False: 0]
  ------------------
 2692|      0|	    memcmp(expect_ed25519_pk, k->ed25519_pk, ED25519_PK_SZ) != 0))) {
  ------------------
  |  |  141|      0|#define	ED25519_PK_SZ	crypto_sign_ed25519_PUBLICKEYBYTES
  |  |  ------------------
  |  |  |  |   60|      0|#define crypto_sign_ed25519_PUBLICKEYBYTES 32U
  |  |  ------------------
  ------------------
  |  Branch (2692:6): [True: 0, False: 0]
  ------------------
 2693|      0|		r = SSH_ERR_KEY_CERT_MISMATCH;
  ------------------
  |  |   69|      0|#define SSH_ERR_KEY_CERT_MISMATCH		-45
  ------------------
 2694|      0|		goto out;
 2695|      0|	}
 2696|       |	/* success */
 2697|      1|	r = 0;
 2698|      1|	if (kp != NULL) {
  ------------------
  |  Branch (2698:6): [True: 1, False: 0]
  ------------------
 2699|      1|		*kp = k;
 2700|      1|		k = NULL;
 2701|      1|	}
 2702|      1| out:
 2703|      1|	free(tname);
 2704|      1|	sshkey_free(k);
 2705|      1|	free(expect_sk_application);
 2706|      1|	free(expect_ed25519_pk);
 2707|      1|	return r;
 2708|      1|}
sshkey_parse_private_fileblob_type:
 3681|      1|{
 3682|      1|	int r = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      1|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 3683|       |
 3684|      1|	if (keyp != NULL)
  ------------------
  |  Branch (3684:6): [True: 1, False: 0]
  ------------------
 3685|      1|		*keyp = NULL;
 3686|      1|	if (commentp != NULL)
  ------------------
  |  Branch (3686:6): [True: 0, False: 1]
  ------------------
 3687|      0|		*commentp = NULL;
 3688|       |
 3689|      1|	r = sshkey_parse_private2(blob, type, passphrase, keyp, commentp);
 3690|       |	/* Only fallback to PEM parser if a format error occurred. */
 3691|      1|	if (r != SSH_ERR_INVALID_FORMAT)
  ------------------
  |  |   28|      1|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  |  Branch (3691:6): [True: 1, False: 0]
  ------------------
 3692|      1|		return r;
 3693|      0|#ifdef WITH_OPENSSL
 3694|      0|	return sshkey_parse_private_pem_fileblob(blob, type,
 3695|      0|	    passphrase, keyp);
 3696|       |#else
 3697|       |	return SSH_ERR_INVALID_FORMAT;
 3698|       |#endif /* WITH_OPENSSL */
 3699|      1|}
sshkey_parse_private_fileblob:
 3704|      1|{
 3705|      1|	if (keyp != NULL)
  ------------------
  |  Branch (3705:6): [True: 1, False: 0]
  ------------------
 3706|      1|		*keyp = NULL;
 3707|      1|	if (commentp != NULL)
  ------------------
  |  Branch (3707:6): [True: 0, False: 1]
  ------------------
 3708|      0|		*commentp = NULL;
 3709|       |
 3710|      1|	return sshkey_parse_private_fileblob_type(buffer, KEY_UNSPEC,
 3711|      1|	    passphrase, keyp, commentp);
 3712|      1|}
sshkey_sig_details_free:
 3716|      2|{
 3717|      2|	freezero(details, sizeof(*details));
 3718|      2|}
sshkey.c:sshkey_impl_from_key:
  181|      8|{
  182|      8|	if (k == NULL)
  ------------------
  |  Branch (182:6): [True: 0, False: 8]
  ------------------
  183|      0|		return NULL;
  184|      8|	return sshkey_impl_from_type_nid(k->type, k->ecdsa_nid);
  185|      8|}
sshkey.c:sshkey_impl_from_type_nid:
  168|     10|{
  169|     10|	int i;
  170|       |
  171|     10|	for (i = 0; keyimpls[i] != NULL; i++) {
  ------------------
  |  Branch (171:14): [True: 10, False: 0]
  ------------------
  172|     10|		if (keyimpls[i]->type == type &&
  ------------------
  |  Branch (172:7): [True: 10, False: 0]
  ------------------
  173|     10|		    (keyimpls[i]->nid == 0 || keyimpls[i]->nid == nid))
  ------------------
  |  Branch (173:8): [True: 10, False: 0]
  |  Branch (173:33): [True: 0, False: 0]
  ------------------
  174|     10|			return keyimpls[i];
  175|     10|	}
  176|      0|	return NULL;
  177|     10|}
sshkey.c:sshkey_impl_from_type:
  156|     35|{
  157|     35|	int i;
  158|       |
  159|    101|	for (i = 0; keyimpls[i] != NULL; i++) {
  ------------------
  |  Branch (159:14): [True: 98, False: 3]
  ------------------
  160|     98|		if (keyimpls[i]->type == type)
  ------------------
  |  Branch (160:7): [True: 32, False: 66]
  ------------------
  161|     32|			return keyimpls[i];
  162|     98|	}
  163|      3|	return NULL;
  164|     35|}
sshkey.c:sshkey_ssh_name_from_type_nid:
  199|      2|{
  200|      2|	const struct sshkey_impl *impl;
  201|       |
  202|      2|	if ((impl = sshkey_impl_from_type_nid(type, nid)) == NULL)
  ------------------
  |  Branch (202:6): [True: 0, False: 2]
  ------------------
  203|      0|		return "ssh-unknown";
  204|      2|	return impl->name;
  205|      2|}
sshkey.c:type_from_name:
  232|     11|{
  233|     11|	int i;
  234|     11|	const struct sshkey_impl *impl;
  235|       |
  236|     55|	for (i = 0; keyimpls[i] != NULL; i++) {
  ------------------
  |  Branch (236:14): [True: 53, False: 2]
  ------------------
  237|     53|		impl = keyimpls[i];
  238|     53|		if (impl->name != NULL && strcmp(name, impl->name) == 0)
  ------------------
  |  Branch (238:7): [True: 53, False: 0]
  |  Branch (238:29): [True: 9, False: 44]
  ------------------
  239|      9|			return impl->type;
  240|       |		/* Only allow shortname matches for plain key types */
  241|     44|		if (allow_short && !impl->cert && impl->shortname != NULL &&
  ------------------
  |  Branch (241:7): [True: 0, False: 44]
  |  Branch (241:22): [True: 0, False: 0]
  |  Branch (241:37): [True: 0, False: 0]
  ------------------
  242|      0|		    strcasecmp(impl->shortname, name) == 0)
  ------------------
  |  Branch (242:7): [True: 0, False: 0]
  ------------------
  243|      0|			return impl->type;
  244|     44|	}
  245|      2|	return KEY_UNSPEC;
  246|     11|}
sshkey.c:key_type_is_ecdsa_variant:
  262|     90|{
  263|     90|	switch (type) {
  ------------------
  |  Branch (263:10): [True: 40, False: 50]
  ------------------
  264|     12|	case KEY_ECDSA:
  ------------------
  |  Branch (264:2): [True: 12, False: 78]
  ------------------
  265|     24|	case KEY_ECDSA_CERT:
  ------------------
  |  Branch (265:2): [True: 12, False: 78]
  ------------------
  266|     32|	case KEY_ECDSA_SK:
  ------------------
  |  Branch (266:2): [True: 8, False: 82]
  ------------------
  267|     40|	case KEY_ECDSA_SK_CERT:
  ------------------
  |  Branch (267:2): [True: 8, False: 82]
  ------------------
  268|     40|		return 1;
  269|     90|	}
  270|     50|	return 0;
  271|     90|}
sshkey.c:sshkey_free_contents:
  768|    860|{
  769|    860|	const struct sshkey_impl *impl;
  770|       |
  771|    860|	if (k == NULL)
  ------------------
  |  Branch (771:6): [True: 858, False: 2]
  ------------------
  772|    858|		return;
  773|      2|	if ((k->flags & SSHKEY_FLAG_EXT) != 0)
  ------------------
  |  |   94|      2|#define SSHKEY_FLAG_EXT		0x0001
  ------------------
  |  Branch (773:6): [True: 0, False: 2]
  ------------------
  774|      0|		pkcs11_key_free(k);
  775|      2|	if ((impl = sshkey_impl_from_type(k->type)) != NULL &&
  ------------------
  |  Branch (775:6): [True: 1, False: 1]
  ------------------
  776|      1|	    impl->funcs->cleanup != NULL)
  ------------------
  |  Branch (776:6): [True: 1, False: 0]
  ------------------
  777|      1|		impl->funcs->cleanup(k);
  778|      2|	if (sshkey_is_cert(k))
  ------------------
  |  Branch (778:6): [True: 0, False: 2]
  ------------------
  779|      0|		cert_free(k->cert);
  780|      2|	freezero(k->shielded_private, k->shielded_len);
  781|      2|	sshkey_prekey_free(k->shield_prekey, k->shield_prekey_len);
  782|      2|}
sshkey.c:to_blob_buf:
  862|      1|{
  863|      1|	int type, ret = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      1|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  864|      1|	const char *typename;
  865|      1|	const struct sshkey_impl *impl;
  866|       |
  867|      1|	if (key == NULL)
  ------------------
  |  Branch (867:6): [True: 0, False: 1]
  ------------------
  868|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  869|       |
  870|      1|	type = force_plain ? sshkey_type_plain(key->type) : key->type;
  ------------------
  |  Branch (870:9): [True: 0, False: 1]
  ------------------
  871|       |
  872|      1|	if (sshkey_type_is_cert(type)) {
  ------------------
  |  Branch (872:6): [True: 0, False: 1]
  ------------------
  873|      0|		if (key->cert == NULL)
  ------------------
  |  Branch (873:7): [True: 0, False: 0]
  ------------------
  874|      0|			return SSH_ERR_EXPECTED_CERT;
  ------------------
  |  |   40|      0|#define SSH_ERR_EXPECTED_CERT			-16
  ------------------
  875|      0|		if (sshbuf_len(key->cert->certblob) == 0)
  ------------------
  |  Branch (875:7): [True: 0, False: 0]
  ------------------
  876|      0|			return SSH_ERR_KEY_LACKS_CERTBLOB;
  ------------------
  |  |   41|      0|#define SSH_ERR_KEY_LACKS_CERTBLOB		-17
  ------------------
  877|       |		/* Use the existing blob */
  878|      0|		if ((ret = sshbuf_putb(b, key->cert->certblob)) != 0)
  ------------------
  |  Branch (878:7): [True: 0, False: 0]
  ------------------
  879|      0|			return ret;
  880|      0|		return 0;
  881|      0|	}
  882|      1|	if ((impl = sshkey_impl_from_type(type)) == NULL)
  ------------------
  |  Branch (882:6): [True: 0, False: 1]
  ------------------
  883|      0|		return SSH_ERR_KEY_TYPE_UNKNOWN;
  ------------------
  |  |   38|      0|#define SSH_ERR_KEY_TYPE_UNKNOWN		-14 /* XXX UNSUPPORTED? */
  ------------------
  884|       |
  885|      1|	typename = sshkey_ssh_name_from_type_nid(type, key->ecdsa_nid);
  886|      1|	if ((ret = sshbuf_put_cstring(b, typename)) != 0)
  ------------------
  |  Branch (886:6): [True: 0, False: 1]
  ------------------
  887|      0|		return ret;
  888|      1|	return impl->funcs->serialize_public(key, b, opts);
  889|      1|}
sshkey.c:peek_type_nid:
 1279|      1|{
 1280|      1|	const struct sshkey_impl *impl;
 1281|      1|	int i;
 1282|       |
 1283|      1|	for (i = 0; keyimpls[i] != NULL; i++) {
  ------------------
  |  Branch (1283:14): [True: 1, False: 0]
  ------------------
 1284|      1|		impl = keyimpls[i];
 1285|      1|		if (impl->name == NULL || strlen(impl->name) != l)
  ------------------
  |  Branch (1285:7): [True: 0, False: 1]
  |  Branch (1285:29): [True: 0, False: 1]
  ------------------
 1286|      0|			continue;
 1287|      1|		if (memcmp(s, impl->name, l) == 0) {
  ------------------
  |  Branch (1287:7): [True: 1, False: 0]
  ------------------
 1288|      1|			*nid = -1;
 1289|      1|			if (key_type_is_ecdsa_variant(impl->type))
  ------------------
  |  Branch (1289:8): [True: 0, False: 1]
  ------------------
 1290|      0|				*nid = impl->nid;
 1291|      1|			return impl->type;
 1292|      1|		}
 1293|      1|	}
 1294|      0|	return KEY_UNSPEC;
 1295|      1|}
sshkey.c:sshkey_prekey_free:
  756|      2|{
  757|      2|#if defined(HAVE_MMAP) && defined(MAP_ANON) && defined(MAP_PRIVATE)
  758|      2|	if (prekey == NULL)
  ------------------
  |  Branch (758:6): [True: 2, False: 0]
  ------------------
  759|      2|		return;
  760|      0|	munmap(prekey, len);
  761|       |#else
  762|       |	free(prekey);
  763|       |#endif /* HAVE_MMAP et al */
  764|      0|}
sshkey.c:private2_check_padding:
 1742|      1|{
 1743|      1|	u_char pad;
 1744|      1|	size_t i;
 1745|      1|	int r;
 1746|       |
 1747|      1|	i = 0;
 1748|      6|	while (sshbuf_len(decrypted)) {
  ------------------
  |  Branch (1748:9): [True: 5, False: 1]
  ------------------
 1749|      5|		if ((r = sshbuf_get_u8(decrypted, &pad)) != 0)
  ------------------
  |  Branch (1749:7): [True: 0, False: 5]
  ------------------
 1750|      0|			goto out;
 1751|      5|		if (pad != (++i & 0xff)) {
  ------------------
  |  Branch (1751:7): [True: 0, False: 5]
  ------------------
 1752|      0|			r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1753|      0|			goto out;
 1754|      0|		}
 1755|      5|	}
 1756|       |	/* success */
 1757|      1|	r = 0;
 1758|      1| out:
 1759|      1|	explicit_bzero(&pad, sizeof(pad));
 1760|      1|	explicit_bzero(&i, sizeof(i));
 1761|      1|	return r;
 1762|      1|}
sshkey.c:sshkey_from_blob_internal:
 2007|      3|{
 2008|      3|	int type, ret = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      3|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 2009|      3|	char *ktype = NULL;
 2010|      3|	struct sshkey *key = NULL;
 2011|      3|	struct sshbuf *copy;
 2012|      3|	const struct sshkey_impl *impl;
 2013|       |
 2014|       |#ifdef DEBUG_PK /* XXX */
 2015|       |	sshbuf_dump(b, stderr);
 2016|       |#endif
 2017|      3|	if (keyp != NULL)
  ------------------
  |  Branch (2017:6): [True: 3, False: 0]
  ------------------
 2018|      3|		*keyp = NULL;
 2019|      3|	if ((copy = sshbuf_fromb(b)) == NULL) {
  ------------------
  |  Branch (2019:6): [True: 0, False: 3]
  ------------------
 2020|      0|		ret = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 2021|      0|		goto out;
 2022|      0|	}
 2023|      3|	if (sshbuf_get_cstring(b, &ktype, NULL) != 0) {
  ------------------
  |  Branch (2023:6): [True: 0, False: 3]
  ------------------
 2024|      0|		ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 2025|      0|		goto out;
 2026|      0|	}
 2027|       |
 2028|      3|	type = sshkey_type_from_name(ktype);
 2029|      3|	if (!allow_cert && sshkey_type_is_cert(type)) {
  ------------------
  |  Branch (2029:6): [True: 0, False: 3]
  |  Branch (2029:21): [True: 0, False: 0]
  ------------------
 2030|      0|		ret = SSH_ERR_KEY_CERT_INVALID_SIGN_KEY;
  ------------------
  |  |   43|      0|#define SSH_ERR_KEY_CERT_INVALID_SIGN_KEY	-19
  ------------------
 2031|      0|		goto out;
 2032|      0|	}
 2033|       |
 2034|      3|	if (alg_allowlist != NULL &&
  ------------------
  |  Branch (2034:6): [True: 1, False: 2]
  ------------------
 2035|      1|	    !sshkey_match_keyname_to_sigalgs(ktype, alg_allowlist)) {
  ------------------
  |  Branch (2035:6): [True: 0, False: 1]
  ------------------
 2036|      0|		ret = SSH_ERR_KEY_ALG_UNSUPPORTED;
  ------------------
  |  |   87|      0|#define SSH_ERR_KEY_ALG_UNSUPPORTED		-63
  ------------------
 2037|      0|		goto out;
 2038|      0|	}
 2039|       |
 2040|      3|	if ((impl = sshkey_impl_from_type(type)) == NULL) {
  ------------------
  |  Branch (2040:6): [True: 0, False: 3]
  ------------------
 2041|      0|		ret = SSH_ERR_KEY_TYPE_UNKNOWN;
  ------------------
  |  |   38|      0|#define SSH_ERR_KEY_TYPE_UNKNOWN		-14 /* XXX UNSUPPORTED? */
  ------------------
 2042|      0|		goto out;
 2043|      0|	}
 2044|      3|	if ((key = sshkey_new(type)) == NULL) {
  ------------------
  |  Branch (2044:6): [True: 0, False: 3]
  ------------------
 2045|      0|		ret = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 2046|      0|		goto out;
 2047|      0|	}
 2048|      3|	if (sshkey_type_is_cert(type)) {
  ------------------
  |  Branch (2048:6): [True: 0, False: 3]
  ------------------
 2049|       |		/* Skip nonce that precedes all certificates */
 2050|      0|		if (sshbuf_get_string_direct(b, NULL, NULL) != 0) {
  ------------------
  |  Branch (2050:7): [True: 0, False: 0]
  ------------------
 2051|      0|			ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 2052|      0|			goto out;
 2053|      0|		}
 2054|      0|	}
 2055|      3|	if ((ret = impl->funcs->deserialize_public(ktype, b, key)) != 0)
  ------------------
  |  Branch (2055:6): [True: 0, False: 3]
  ------------------
 2056|      0|		goto out;
 2057|       |
 2058|       |	/* Parse certificate potion */
 2059|      3|	if (sshkey_is_cert(key) &&
  ------------------
  |  Branch (2059:6): [True: 0, False: 3]
  ------------------
 2060|      0|	    (ret = cert_parse(b, key, copy, ca_sigalg_allowlist)) != 0)
  ------------------
  |  Branch (2060:6): [True: 0, False: 0]
  ------------------
 2061|      0|		goto out;
 2062|       |
 2063|      3|	if (key != NULL && sshbuf_len(b) != 0) {
  ------------------
  |  Branch (2063:6): [True: 3, False: 0]
  |  Branch (2063:21): [True: 0, False: 3]
  ------------------
 2064|      0|		ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 2065|      0|		goto out;
 2066|      0|	}
 2067|      3|	ret = 0;
 2068|      3|	if (keyp != NULL) {
  ------------------
  |  Branch (2068:6): [True: 3, False: 0]
  ------------------
 2069|      3|		*keyp = key;
 2070|      3|		key = NULL;
 2071|      3|	}
 2072|      3| out:
 2073|      3|	sshbuf_free(copy);
 2074|      3|	sshkey_free(key);
 2075|      3|	free(ktype);
 2076|      3|	return ret;
 2077|      3|}
sshkey.c:sshkey_parse_private2:
 3207|      1|{
 3208|      1|	char *comment = NULL;
 3209|      1|	int r = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      1|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 3210|      1|	struct sshbuf *decoded = NULL, *decrypted = NULL;
 3211|      1|	struct sshkey *k = NULL, *pubkey = NULL;
 3212|       |
 3213|      1|	if (keyp != NULL)
  ------------------
  |  Branch (3213:6): [True: 1, False: 0]
  ------------------
 3214|      1|		*keyp = NULL;
 3215|      1|	if (commentp != NULL)
  ------------------
  |  Branch (3215:6): [True: 0, False: 1]
  ------------------
 3216|      0|		*commentp = NULL;
 3217|       |
 3218|       |	/* Undo base64 encoding and decrypt the private section */
 3219|      1|	if ((r = private2_uudecode(blob, &decoded)) != 0 ||
  ------------------
  |  Branch (3219:6): [True: 0, False: 1]
  ------------------
 3220|      1|	    (r = private2_decrypt(decoded, passphrase,
  ------------------
  |  Branch (3220:6): [True: 0, False: 1]
  ------------------
 3221|      1|	    &decrypted, &pubkey)) != 0)
 3222|      0|		goto out;
 3223|       |
 3224|      1|	if (type != KEY_UNSPEC &&
  ------------------
  |  Branch (3224:6): [True: 0, False: 1]
  ------------------
 3225|      0|	    sshkey_type_plain(type) != sshkey_type_plain(pubkey->type)) {
  ------------------
  |  Branch (3225:6): [True: 0, False: 0]
  ------------------
 3226|      0|		r = SSH_ERR_KEY_TYPE_MISMATCH;
  ------------------
  |  |   37|      0|#define SSH_ERR_KEY_TYPE_MISMATCH		-13
  ------------------
 3227|      0|		goto out;
 3228|      0|	}
 3229|       |
 3230|       |	/* Load the private key and comment */
 3231|      1|	if ((r = sshkey_private_deserialize(decrypted, &k)) != 0 ||
  ------------------
  |  Branch (3231:6): [True: 0, False: 1]
  ------------------
 3232|      1|	    (r = sshbuf_get_cstring(decrypted, &comment, NULL)) != 0)
  ------------------
  |  Branch (3232:6): [True: 0, False: 1]
  ------------------
 3233|      0|		goto out;
 3234|       |
 3235|       |	/* Check deterministic padding after private section */
 3236|      1|	if ((r = private2_check_padding(decrypted)) != 0)
  ------------------
  |  Branch (3236:6): [True: 0, False: 1]
  ------------------
 3237|      0|		goto out;
 3238|       |
 3239|       |	/* Check that the public key in the envelope matches the private key */
 3240|      1|	if (!sshkey_equal(pubkey, k)) {
  ------------------
  |  Branch (3240:6): [True: 0, False: 1]
  ------------------
 3241|      0|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 3242|      0|		goto out;
 3243|      0|	}
 3244|       |
 3245|       |	/* success */
 3246|      1|	r = 0;
 3247|      1|	if (keyp != NULL) {
  ------------------
  |  Branch (3247:6): [True: 1, False: 0]
  ------------------
 3248|      1|		*keyp = k;
 3249|      1|		k = NULL;
 3250|      1|	}
 3251|      1|	if (commentp != NULL) {
  ------------------
  |  Branch (3251:6): [True: 0, False: 1]
  ------------------
 3252|      0|		*commentp = comment;
 3253|      0|		comment = NULL;
 3254|      0|	}
 3255|      1| out:
 3256|      1|	free(comment);
 3257|      1|	sshbuf_free(decoded);
 3258|      1|	sshbuf_free(decrypted);
 3259|      1|	sshkey_free(k);
 3260|      1|	sshkey_free(pubkey);
 3261|      1|	return r;
 3262|      1|}
sshkey.c:private2_uudecode:
 2980|      1|{
 2981|      1|	const u_char *cp;
 2982|      1|	size_t encoded_len;
 2983|      1|	int r;
 2984|      1|	u_char last;
 2985|      1|	struct sshbuf *encoded = NULL, *decoded = NULL;
 2986|       |
 2987|      1|	if (blob == NULL || decodedp == NULL)
  ------------------
  |  Branch (2987:6): [True: 0, False: 1]
  |  Branch (2987:22): [True: 0, False: 1]
  ------------------
 2988|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
 2989|       |
 2990|      1|	*decodedp = NULL;
 2991|       |
 2992|      1|	if ((encoded = sshbuf_new()) == NULL ||
  ------------------
  |  Branch (2992:6): [True: 0, False: 1]
  ------------------
 2993|      1|	    (decoded = sshbuf_new()) == NULL) {
  ------------------
  |  Branch (2993:6): [True: 0, False: 1]
  ------------------
 2994|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 2995|      0|		goto out;
 2996|      0|	}
 2997|       |
 2998|       |	/* check preamble */
 2999|      1|	cp = sshbuf_ptr(blob);
 3000|      1|	encoded_len = sshbuf_len(blob);
 3001|      1|	if (encoded_len < (MARK_BEGIN_LEN + MARK_END_LEN) ||
  ------------------
  |  |   69|      1|#define MARK_BEGIN_LEN		(sizeof(MARK_BEGIN) - 1)
  |  |  ------------------
  |  |  |  |   67|      1|#define MARK_BEGIN		"-----BEGIN OPENSSH PRIVATE KEY-----\n"
  |  |  ------------------
  ------------------
              	if (encoded_len < (MARK_BEGIN_LEN + MARK_END_LEN) ||
  ------------------
  |  |   70|      1|#define MARK_END_LEN		(sizeof(MARK_END) - 1)
  |  |  ------------------
  |  |  |  |   68|      1|#define MARK_END		"-----END OPENSSH PRIVATE KEY-----\n"
  |  |  ------------------
  ------------------
  |  Branch (3001:6): [True: 0, False: 1]
  ------------------
 3002|      1|	    memcmp(cp, MARK_BEGIN, MARK_BEGIN_LEN) != 0) {
  ------------------
  |  |   67|      1|#define MARK_BEGIN		"-----BEGIN OPENSSH PRIVATE KEY-----\n"
  ------------------
              	    memcmp(cp, MARK_BEGIN, MARK_BEGIN_LEN) != 0) {
  ------------------
  |  |   69|      1|#define MARK_BEGIN_LEN		(sizeof(MARK_BEGIN) - 1)
  |  |  ------------------
  |  |  |  |   67|      1|#define MARK_BEGIN		"-----BEGIN OPENSSH PRIVATE KEY-----\n"
  |  |  ------------------
  ------------------
  |  Branch (3002:6): [True: 0, False: 1]
  ------------------
 3003|      0|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 3004|      0|		goto out;
 3005|      0|	}
 3006|      1|	cp += MARK_BEGIN_LEN;
  ------------------
  |  |   69|      1|#define MARK_BEGIN_LEN		(sizeof(MARK_BEGIN) - 1)
  |  |  ------------------
  |  |  |  |   67|      1|#define MARK_BEGIN		"-----BEGIN OPENSSH PRIVATE KEY-----\n"
  |  |  ------------------
  ------------------
 3007|      1|	encoded_len -= MARK_BEGIN_LEN;
  ------------------
  |  |   69|      1|#define MARK_BEGIN_LEN		(sizeof(MARK_BEGIN) - 1)
  |  |  ------------------
  |  |  |  |   67|      1|#define MARK_BEGIN		"-----BEGIN OPENSSH PRIVATE KEY-----\n"
  |  |  ------------------
  ------------------
 3008|       |
 3009|       |	/* Look for end marker, removing whitespace as we go */
 3010|    317|	while (encoded_len > 0) {
  ------------------
  |  Branch (3010:9): [True: 317, False: 0]
  ------------------
 3011|    317|		if (*cp != '\n' && *cp != '\r') {
  ------------------
  |  Branch (3011:7): [True: 312, False: 5]
  |  Branch (3011:22): [True: 312, False: 0]
  ------------------
 3012|    312|			if ((r = sshbuf_put_u8(encoded, *cp)) != 0)
  ------------------
  |  Branch (3012:8): [True: 0, False: 312]
  ------------------
 3013|      0|				goto out;
 3014|    312|		}
 3015|    317|		last = *cp;
 3016|    317|		encoded_len--;
 3017|    317|		cp++;
 3018|    317|		if (last == '\n') {
  ------------------
  |  Branch (3018:7): [True: 5, False: 312]
  ------------------
 3019|      5|			if (encoded_len >= MARK_END_LEN &&
  ------------------
  |  |   70|     10|#define MARK_END_LEN		(sizeof(MARK_END) - 1)
  |  |  ------------------
  |  |  |  |   68|      5|#define MARK_END		"-----END OPENSSH PRIVATE KEY-----\n"
  |  |  ------------------
  ------------------
  |  Branch (3019:8): [True: 5, False: 0]
  ------------------
 3020|      5|			    memcmp(cp, MARK_END, MARK_END_LEN) == 0) {
  ------------------
  |  |   68|      5|#define MARK_END		"-----END OPENSSH PRIVATE KEY-----\n"
  ------------------
              			    memcmp(cp, MARK_END, MARK_END_LEN) == 0) {
  ------------------
  |  |   70|      5|#define MARK_END_LEN		(sizeof(MARK_END) - 1)
  |  |  ------------------
  |  |  |  |   68|      5|#define MARK_END		"-----END OPENSSH PRIVATE KEY-----\n"
  |  |  ------------------
  ------------------
  |  Branch (3020:8): [True: 1, False: 4]
  ------------------
 3021|       |				/* \0 terminate */
 3022|      1|				if ((r = sshbuf_put_u8(encoded, 0)) != 0)
  ------------------
  |  Branch (3022:9): [True: 0, False: 1]
  ------------------
 3023|      0|					goto out;
 3024|      1|				break;
 3025|      1|			}
 3026|      5|		}
 3027|    317|	}
 3028|      1|	if (encoded_len == 0) {
  ------------------
  |  Branch (3028:6): [True: 0, False: 1]
  ------------------
 3029|      0|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 3030|      0|		goto out;
 3031|      0|	}
 3032|       |
 3033|       |	/* decode base64 */
 3034|      1|	if ((r = sshbuf_b64tod(decoded, (char *)sshbuf_ptr(encoded))) != 0)
  ------------------
  |  Branch (3034:6): [True: 0, False: 1]
  ------------------
 3035|      0|		goto out;
 3036|       |
 3037|       |	/* check magic */
 3038|      1|	if (sshbuf_len(decoded) < sizeof(AUTH_MAGIC) ||
  ------------------
  |  |   72|      1|#define AUTH_MAGIC		"openssh-key-v1"
  ------------------
  |  Branch (3038:6): [True: 0, False: 1]
  ------------------
 3039|      1|	    memcmp(sshbuf_ptr(decoded), AUTH_MAGIC, sizeof(AUTH_MAGIC))) {
  ------------------
  |  |   72|      1|#define AUTH_MAGIC		"openssh-key-v1"
  ------------------
              	    memcmp(sshbuf_ptr(decoded), AUTH_MAGIC, sizeof(AUTH_MAGIC))) {
  ------------------
  |  |   72|      1|#define AUTH_MAGIC		"openssh-key-v1"
  ------------------
  |  Branch (3039:6): [True: 0, False: 1]
  ------------------
 3040|      0|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 3041|      0|		goto out;
 3042|      0|	}
 3043|       |	/* success */
 3044|      1|	*decodedp = decoded;
 3045|      1|	decoded = NULL;
 3046|      1|	r = 0;
 3047|      1| out:
 3048|      1|	sshbuf_free(encoded);
 3049|      1|	sshbuf_free(decoded);
 3050|      1|	return r;
 3051|      1|}
sshkey.c:private2_decrypt:
 3056|      1|{
 3057|      1|	char *ciphername = NULL, *kdfname = NULL;
 3058|      1|	const struct sshcipher *cipher = NULL;
 3059|      1|	int r = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      1|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 3060|      1|	size_t keylen = 0, ivlen = 0, authlen = 0, slen = 0;
 3061|      1|	struct sshbuf *kdf = NULL, *decrypted = NULL;
 3062|      1|	struct sshcipher_ctx *ciphercontext = NULL;
 3063|      1|	struct sshkey *pubkey = NULL;
 3064|      1|	u_char *key = NULL, *salt = NULL, *dp;
 3065|      1|	u_int blocksize, rounds, nkeys, encrypted_len, check1, check2;
 3066|       |
 3067|      1|	if (decoded == NULL || decryptedp == NULL || pubkeyp == NULL)
  ------------------
  |  Branch (3067:6): [True: 0, False: 1]
  |  Branch (3067:25): [True: 0, False: 1]
  |  Branch (3067:47): [True: 0, False: 1]
  ------------------
 3068|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
 3069|       |
 3070|      1|	*decryptedp = NULL;
 3071|      1|	*pubkeyp = NULL;
 3072|       |
 3073|      1|	if ((decrypted = sshbuf_new()) == NULL) {
  ------------------
  |  Branch (3073:6): [True: 0, False: 1]
  ------------------
 3074|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 3075|      0|		goto out;
 3076|      0|	}
 3077|       |
 3078|       |	/* parse public portion of key */
 3079|      1|	if ((r = sshbuf_consume(decoded, sizeof(AUTH_MAGIC))) != 0 ||
  ------------------
  |  |   72|      1|#define AUTH_MAGIC		"openssh-key-v1"
  ------------------
  |  Branch (3079:6): [True: 0, False: 1]
  ------------------
 3080|      1|	    (r = sshbuf_get_cstring(decoded, &ciphername, NULL)) != 0 ||
  ------------------
  |  Branch (3080:6): [True: 0, False: 1]
  ------------------
 3081|      1|	    (r = sshbuf_get_cstring(decoded, &kdfname, NULL)) != 0 ||
  ------------------
  |  Branch (3081:6): [True: 0, False: 1]
  ------------------
 3082|      1|	    (r = sshbuf_froms(decoded, &kdf)) != 0 ||
  ------------------
  |  Branch (3082:6): [True: 0, False: 1]
  ------------------
 3083|      1|	    (r = sshbuf_get_u32(decoded, &nkeys)) != 0)
  ------------------
  |  Branch (3083:6): [True: 0, False: 1]
  ------------------
 3084|      0|		goto out;
 3085|       |
 3086|      1|	if (nkeys != 1) {
  ------------------
  |  Branch (3086:6): [True: 0, False: 1]
  ------------------
 3087|       |		/* XXX only one key supported at present */
 3088|      0|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 3089|      0|		goto out;
 3090|      0|	}
 3091|       |
 3092|      1|	if ((r = sshkey_froms(decoded, &pubkey)) != 0 ||
  ------------------
  |  Branch (3092:6): [True: 0, False: 1]
  ------------------
 3093|      1|	    (r = sshbuf_get_u32(decoded, &encrypted_len)) != 0)
  ------------------
  |  Branch (3093:6): [True: 0, False: 1]
  ------------------
 3094|      0|		goto out;
 3095|       |
 3096|      1|	if ((cipher = cipher_by_name(ciphername)) == NULL) {
  ------------------
  |  Branch (3096:6): [True: 0, False: 1]
  ------------------
 3097|      0|		r = SSH_ERR_KEY_UNKNOWN_CIPHER;
  ------------------
  |  |   66|      0|#define SSH_ERR_KEY_UNKNOWN_CIPHER		-42
  ------------------
 3098|      0|		goto out;
 3099|      0|	}
 3100|      1|	if (strcmp(kdfname, "none") != 0 && strcmp(kdfname, "bcrypt") != 0) {
  ------------------
  |  Branch (3100:6): [True: 0, False: 1]
  |  Branch (3100:38): [True: 0, False: 0]
  ------------------
 3101|      0|		r = SSH_ERR_KEY_UNKNOWN_CIPHER;
  ------------------
  |  |   66|      0|#define SSH_ERR_KEY_UNKNOWN_CIPHER		-42
  ------------------
 3102|      0|		goto out;
 3103|      0|	}
 3104|      1|	if (strcmp(kdfname, "none") == 0 && strcmp(ciphername, "none") != 0) {
  ------------------
  |  Branch (3104:6): [True: 1, False: 0]
  |  Branch (3104:38): [True: 0, False: 1]
  ------------------
 3105|      0|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 3106|      0|		goto out;
 3107|      0|	}
 3108|      1|	if ((passphrase == NULL || strlen(passphrase) == 0) &&
  ------------------
  |  Branch (3108:7): [True: 0, False: 1]
  |  Branch (3108:29): [True: 1, False: 0]
  ------------------
 3109|      1|	    strcmp(kdfname, "none") != 0) {
  ------------------
  |  Branch (3109:6): [True: 0, False: 1]
  ------------------
 3110|       |		/* passphrase required */
 3111|      0|		r = SSH_ERR_KEY_WRONG_PASSPHRASE;
  ------------------
  |  |   67|      0|#define SSH_ERR_KEY_WRONG_PASSPHRASE		-43
  ------------------
 3112|      0|		goto out;
 3113|      0|	}
 3114|       |
 3115|       |	/* check size of encrypted key blob */
 3116|      1|	blocksize = cipher_blocksize(cipher);
 3117|      1|	if (encrypted_len < blocksize || (encrypted_len % blocksize) != 0) {
  ------------------
  |  Branch (3117:6): [True: 0, False: 1]
  |  Branch (3117:35): [True: 0, False: 1]
  ------------------
 3118|      0|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 3119|      0|		goto out;
 3120|      0|	}
 3121|       |
 3122|       |	/* setup key */
 3123|      1|	keylen = cipher_keylen(cipher);
 3124|      1|	ivlen = cipher_ivlen(cipher);
 3125|      1|	authlen = cipher_authlen(cipher);
 3126|      1|	if ((key = calloc(1, keylen + ivlen)) == NULL) {
  ------------------
  |  Branch (3126:6): [True: 0, False: 1]
  ------------------
 3127|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 3128|      0|		goto out;
 3129|      0|	}
 3130|      1|	if (strcmp(kdfname, "bcrypt") == 0) {
  ------------------
  |  Branch (3130:6): [True: 0, False: 1]
  ------------------
 3131|      0|		if ((r = sshbuf_get_string(kdf, &salt, &slen)) != 0 ||
  ------------------
  |  Branch (3131:7): [True: 0, False: 0]
  ------------------
 3132|      0|		    (r = sshbuf_get_u32(kdf, &rounds)) != 0)
  ------------------
  |  Branch (3132:7): [True: 0, False: 0]
  ------------------
 3133|      0|			goto out;
 3134|      0|		if (rounds > MAX_KDF_ROUNDS) {
  ------------------
  |  |   76|      0|#define	MAX_KDF_ROUNDS		(1<<20)
  ------------------
  |  Branch (3134:7): [True: 0, False: 0]
  ------------------
 3135|      0|			r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 3136|      0|			goto out;
 3137|      0|		}
 3138|      0|		if (bcrypt_pbkdf(passphrase, strlen(passphrase), salt, slen,
  ------------------
  |  Branch (3138:7): [True: 0, False: 0]
  ------------------
 3139|      0|		    key, keylen + ivlen, rounds) < 0) {
 3140|      0|			r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 3141|      0|			goto out;
 3142|      0|		}
 3143|      0|	}
 3144|       |
 3145|       |	/* check that an appropriate amount of auth data is present */
 3146|      1|	if (sshbuf_len(decoded) < authlen ||
  ------------------
  |  Branch (3146:6): [True: 0, False: 1]
  ------------------
 3147|      1|	    sshbuf_len(decoded) - authlen < encrypted_len) {
  ------------------
  |  Branch (3147:6): [True: 0, False: 1]
  ------------------
 3148|      0|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 3149|      0|		goto out;
 3150|      0|	}
 3151|       |
 3152|       |	/* decrypt private portion of key */
 3153|      1|	if ((r = sshbuf_reserve(decrypted, encrypted_len, &dp)) != 0 ||
  ------------------
  |  Branch (3153:6): [True: 0, False: 1]
  ------------------
 3154|      1|	    (r = cipher_init(&ciphercontext, cipher, key, keylen,
  ------------------
  |  Branch (3154:6): [True: 0, False: 1]
  ------------------
 3155|      1|	    key + keylen, ivlen, 0)) != 0)
 3156|      0|		goto out;
 3157|      1|	if ((r = cipher_crypt(ciphercontext, 0, dp, sshbuf_ptr(decoded),
  ------------------
  |  Branch (3157:6): [True: 0, False: 1]
  ------------------
 3158|      1|	    encrypted_len, 0, authlen)) != 0) {
 3159|       |		/* an integrity error here indicates an incorrect passphrase */
 3160|      0|		if (r == SSH_ERR_MAC_INVALID)
  ------------------
  |  |   54|      0|#define SSH_ERR_MAC_INVALID			-30
  ------------------
  |  Branch (3160:7): [True: 0, False: 0]
  ------------------
 3161|      0|			r = SSH_ERR_KEY_WRONG_PASSPHRASE;
  ------------------
  |  |   67|      0|#define SSH_ERR_KEY_WRONG_PASSPHRASE		-43
  ------------------
 3162|      0|		goto out;
 3163|      0|	}
 3164|      1|	if ((r = sshbuf_consume(decoded, encrypted_len + authlen)) != 0)
  ------------------
  |  Branch (3164:6): [True: 0, False: 1]
  ------------------
 3165|      0|		goto out;
 3166|       |	/* there should be no trailing data */
 3167|      1|	if (sshbuf_len(decoded) != 0) {
  ------------------
  |  Branch (3167:6): [True: 0, False: 1]
  ------------------
 3168|      0|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 3169|      0|		goto out;
 3170|      0|	}
 3171|       |
 3172|       |	/* check check bytes */
 3173|      1|	if ((r = sshbuf_get_u32(decrypted, &check1)) != 0 ||
  ------------------
  |  Branch (3173:6): [True: 0, False: 1]
  ------------------
 3174|      1|	    (r = sshbuf_get_u32(decrypted, &check2)) != 0)
  ------------------
  |  Branch (3174:6): [True: 0, False: 1]
  ------------------
 3175|      0|		goto out;
 3176|      1|	if (check1 != check2) {
  ------------------
  |  Branch (3176:6): [True: 0, False: 1]
  ------------------
 3177|      0|		r = SSH_ERR_KEY_WRONG_PASSPHRASE;
  ------------------
  |  |   67|      0|#define SSH_ERR_KEY_WRONG_PASSPHRASE		-43
  ------------------
 3178|      0|		goto out;
 3179|      0|	}
 3180|       |	/* success */
 3181|      1|	*decryptedp = decrypted;
 3182|      1|	decrypted = NULL;
 3183|      1|	*pubkeyp = pubkey;
 3184|      1|	pubkey = NULL;
 3185|      1|	r = 0;
 3186|      1| out:
 3187|      1|	cipher_free(ciphercontext);
 3188|      1|	free(ciphername);
 3189|      1|	free(kdfname);
 3190|      1|	sshkey_free(pubkey);
 3191|      1|	if (salt != NULL) {
  ------------------
  |  Branch (3191:6): [True: 0, False: 1]
  ------------------
 3192|      0|		explicit_bzero(salt, slen);
 3193|      0|		free(salt);
 3194|      0|	}
 3195|      1|	if (key != NULL) {
  ------------------
  |  Branch (3195:6): [True: 1, False: 0]
  ------------------
 3196|      1|		explicit_bzero(key, keylen + ivlen);
 3197|      1|		free(key);
 3198|      1|	}
 3199|      1|	sshbuf_free(kdf);
 3200|      1|	sshbuf_free(decrypted);
 3201|      1|	return r;
 3202|      1|}

xmalloc:
   33|  1.07k|{
   34|  1.07k|	void *ptr;
   35|       |
   36|  1.07k|	if (size == 0)
  ------------------
  |  Branch (36:6): [True: 0, False: 1.07k]
  ------------------
   37|      0|		fatal("xmalloc: zero size");
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
   38|  1.07k|	ptr = malloc(size);
   39|  1.07k|	if (ptr == NULL)
  ------------------
  |  Branch (39:6): [True: 0, False: 1.07k]
  ------------------
   40|      0|		fatal("xmalloc: out of memory (allocating %zu bytes)", size);
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
   41|  1.07k|	return ptr;
   42|  1.07k|}
xcalloc:
   46|  1.91k|{
   47|  1.91k|	void *ptr;
   48|       |
   49|  1.91k|	if (size == 0 || nmemb == 0)
  ------------------
  |  Branch (49:6): [True: 0, False: 1.91k]
  |  Branch (49:19): [True: 0, False: 1.91k]
  ------------------
   50|      0|		fatal("xcalloc: zero size");
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
   51|  1.91k|	if (SIZE_MAX / nmemb < size)
  ------------------
  |  Branch (51:6): [True: 0, False: 1.91k]
  ------------------
   52|      0|		fatal("xcalloc: nmemb * size > SIZE_MAX");
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
   53|  1.91k|	ptr = calloc(nmemb, size);
   54|  1.91k|	if (ptr == NULL)
  ------------------
  |  Branch (54:6): [True: 0, False: 1.91k]
  ------------------
   55|      0|		fatal("xcalloc: out of memory (allocating %zu bytes)",
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
   56|  1.91k|		    size * nmemb);
   57|  1.91k|	return ptr;
   58|  1.91k|}
xrecallocarray:
   74|     11|{
   75|     11|	void *new_ptr;
   76|       |
   77|     11|	new_ptr = recallocarray(ptr, onmemb, nmemb, size);
   78|     11|	if (new_ptr == NULL)
  ------------------
  |  Branch (78:6): [True: 0, False: 11]
  ------------------
   79|      0|		fatal("xrecallocarray: out of memory (%zu elements of %zu bytes)",
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
   80|     11|		    nmemb, size);
   81|     11|	return new_ptr;
   82|     11|}
xstrdup:
   86|    781|{
   87|    781|	size_t len;
   88|    781|	char *cp;
   89|       |
   90|    781|	len = strlen(str) + 1;
   91|    781|	cp = xmalloc(len);
   92|    781|	return memcpy(cp, str, len);
   93|    781|}
xvasprintf:
   97|    168|{
   98|    168|	int i;
   99|       |
  100|    168|	i = vasprintf(ret, fmt, ap);
  101|    168|	if (i < 0 || *ret == NULL)
  ------------------
  |  Branch (101:6): [True: 0, False: 168]
  |  Branch (101:15): [True: 0, False: 168]
  ------------------
  102|      0|		fatal("xvasprintf: could not allocate memory");
  ------------------
  |  |  115|      0|#define fatal(...)		sshfatal(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_FATAL, NULL, __VA_ARGS__)
  ------------------
  103|    168|	return i;
  104|    168|}
xasprintf:
  108|     81|{
  109|     81|	va_list ap;
  110|     81|	int i;
  111|       |
  112|     81|	va_start(ap, fmt);
  113|     81|	i = xvasprintf(ret, fmt, ap);
  114|       |	va_end(ap);
  115|     81|	return i;
  116|     81|}

