|
Dmitry Belyavskiy |
9fd698 |
diff --color -rup a/regress/hostkey-agent.sh b/regress/hostkey-agent.sh
|
|
Dmitry Belyavskiy |
9fd698 |
--- a/regress/hostkey-agent.sh 2021-08-20 06:03:49.000000000 +0200
|
|
Dmitry Belyavskiy |
9fd698 |
+++ b/regress/hostkey-agent.sh 2022-07-14 11:58:12.172786060 +0200
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -13,8 +13,12 @@ r=$?
|
|
Dmitry Belyavskiy |
03150f |
|
|
Dmitry Belyavskiy |
03150f |
${SSHKEYGEN} -qt ed25519 -f $OBJ/agent-ca -N '' || fatal "ssh-keygen CA"
|
|
Dmitry Belyavskiy |
9fd698 |
|
|
Dmitry Belyavskiy |
9fd698 |
+PUBKEY_ACCEPTED_ALGOS=`$SSH -G "example.com" | \
|
|
Dmitry Belyavskiy |
9fd698 |
+ grep -i "PubkeyAcceptedAlgorithms" | cut -d ' ' -f2- | tr "," "|"`
|
|
Dmitry Belyavskiy |
9fd698 |
+SSH_ACCEPTED_KEYTYPES=`echo "$SSH_KEYTYPES" | egrep "$PUBKEY_ACCEPTED_ALGOS"`
|
|
Dmitry Belyavskiy |
9fd698 |
+
|
|
Dmitry Belyavskiy |
9fd698 |
trace "load hostkeys"
|
|
Dmitry Belyavskiy |
9fd698 |
-for k in $SSH_KEYTYPES ; do
|
|
Dmitry Belyavskiy |
9fd698 |
+for k in $SSH_ACCEPTED_KEYTYPES ; do
|
|
Dmitry Belyavskiy |
03150f |
${SSHKEYGEN} -qt $k -f $OBJ/agent-key.$k -N '' || fatal "ssh-keygen $k"
|
|
Dmitry Belyavskiy |
03150f |
${SSHKEYGEN} -s $OBJ/agent-ca -qh -n localhost-with-alias \
|
|
Dmitry Belyavskiy |
03150f |
-I localhost-with-alias $OBJ/agent-key.$k.pub || \
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -31,7 +35,7 @@ cp $OBJ/known_hosts.orig $OBJ/known_host
|
|
Dmitry Belyavskiy |
03150f |
|
|
Dmitry Belyavskiy |
9fd698 |
unset SSH_AUTH_SOCK
|
|
Dmitry Belyavskiy |
9fd698 |
|
|
Dmitry Belyavskiy |
03150f |
-for k in $SSH_KEYTYPES ; do
|
|
Dmitry Belyavskiy |
03150f |
+for k in $SSH_ACCEPTED_KEYTYPES ; do
|
|
Dmitry Belyavskiy |
03150f |
verbose "key type $k"
|
|
Dmitry Belyavskiy |
03150f |
cp $OBJ/sshd_proxy.orig $OBJ/sshd_proxy
|
|
Dmitry Belyavskiy |
03150f |
echo "HostKeyAlgorithms $k" >> $OBJ/sshd_proxy
|
|
Dmitry Belyavskiy |
9fd698 |
diff --color -rup a/sshconnect2.c b/sshconnect2.c
|
|
Dmitry Belyavskiy |
9fd698 |
--- a/sshconnect2.c 2022-07-14 10:10:07.262975710 +0200
|
|
Dmitry Belyavskiy |
9fd698 |
+++ b/sshconnect2.c 2022-07-14 10:10:32.068452067 +0200
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -222,6 +222,7 @@ ssh_kex2(struct ssh *ssh, char *host, st
|
|
Dmitry Belyavskiy |
9fd698 |
{
|
|
Dmitry Belyavskiy |
9fd698 |
char *myproposal[PROPOSAL_MAX] = { KEX_CLIENT };
|
|
Dmitry Belyavskiy |
9fd698 |
char *s, *all_key;
|
|
Dmitry Belyavskiy |
9fd698 |
+ char *hostkeyalgs = NULL, *pkalg = NULL;
|
|
Dmitry Belyavskiy |
9fd698 |
char *prop_kex = NULL, *prop_enc = NULL, *prop_hostkey = NULL;
|
|
Dmitry Belyavskiy |
9fd698 |
int r, use_known_hosts_order = 0;
|
|
Dmitry Belyavskiy |
9fd698 |
|
|
Dmitry Belyavskiy |
9fd698 |
@@ -264,14 +265,19 @@ ssh_kex2(struct ssh *ssh, char *host, st
|
|
Dmitry Belyavskiy |
9fd698 |
myproposal[PROPOSAL_MAC_ALGS_STOC] = options.macs;
|
|
Dmitry Belyavskiy |
9fd698 |
if (use_known_hosts_order) {
|
|
Dmitry Belyavskiy |
9fd698 |
/* Query known_hosts and prefer algorithms that appear there */
|
|
Dmitry Belyavskiy |
9fd698 |
- myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = prop_hostkey =
|
|
Dmitry Belyavskiy |
9fd698 |
- compat_pkalg_proposal(ssh,
|
|
Dmitry Belyavskiy |
9fd698 |
- order_hostkeyalgs(host, hostaddr, port, cinfo));
|
|
Dmitry Belyavskiy |
9fd698 |
+ if ((hostkeyalgs = order_hostkeyalgs(host, hostaddr, port, cinfo)) == NULL)
|
|
Dmitry Belyavskiy |
9fd698 |
+ fatal_f("order_hostkeyalgs");
|
|
Dmitry Belyavskiy |
9fd698 |
+ pkalg = match_filter_allowlist(hostkeyalgs, options.pubkey_accepted_algos);
|
|
Dmitry Belyavskiy |
9fd698 |
+ free(hostkeyalgs);
|
|
Dmitry Belyavskiy |
9fd698 |
} else {
|
|
Dmitry Belyavskiy |
9fd698 |
- /* Use specified HostkeyAlgorithms exactly */
|
|
Dmitry Belyavskiy |
9fd698 |
- myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = prop_hostkey =
|
|
Dmitry Belyavskiy |
9fd698 |
- compat_pkalg_proposal(ssh, options.hostkeyalgorithms);
|
|
Dmitry Belyavskiy |
9fd698 |
+ /* Use specified HostkeyAlgorithms */
|
|
Dmitry Belyavskiy |
9fd698 |
+ pkalg = match_filter_allowlist(options.hostkeyalgorithms, options.pubkey_accepted_algos);
|
|
Dmitry Belyavskiy |
9fd698 |
}
|
|
Dmitry Belyavskiy |
9fd698 |
+ if (pkalg == NULL)
|
|
Dmitry Belyavskiy |
9fd698 |
+ fatal_f("match_filter_allowlist");
|
|
Dmitry Belyavskiy |
9fd698 |
+ myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = prop_hostkey =
|
|
Dmitry Belyavskiy |
9fd698 |
+ compat_pkalg_proposal(ssh, pkalg);
|
|
Dmitry Belyavskiy |
9fd698 |
+ free(pkalg);
|
|
Dmitry Belyavskiy |
9fd698 |
|
|
Dmitry Belyavskiy |
9fd698 |
#if defined(GSSAPI) && defined(WITH_OPENSSL)
|
|
Dmitry Belyavskiy |
9fd698 |
if (options.gss_keyex) {
|