2023-03-02 08:14:52 +00:00
|
|
|
# $OpenBSD: dhgex.sh,v 1.8 2023/03/02 08:14:52 dtucker Exp $
|
2014-02-27 23:21:26 +00:00
|
|
|
# Placed in the Public Domain.
|
|
|
|
|
|
|
|
tid="dhgex"
|
|
|
|
|
|
|
|
LOG=${TEST_SSH_LOGFILE}
|
|
|
|
rm -f ${LOG}
|
2014-05-15 05:07:53 +00:00
|
|
|
cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
|
2014-02-27 23:21:26 +00:00
|
|
|
|
|
|
|
kexs=`${SSH} -Q kex | grep diffie-hellman-group-exchange`
|
|
|
|
|
|
|
|
ssh_test_dhgex()
|
|
|
|
{
|
|
|
|
bits="$1"; shift
|
|
|
|
cipher="$1"; shift
|
|
|
|
kex="$1"; shift
|
|
|
|
|
2014-05-15 05:07:53 +00:00
|
|
|
cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
|
|
|
|
echo "KexAlgorithms=$kex" >> $OBJ/sshd_proxy
|
|
|
|
echo "Ciphers=$cipher" >> $OBJ/sshd_proxy
|
2014-02-27 23:21:26 +00:00
|
|
|
rm -f ${LOG}
|
|
|
|
opts="-oKexAlgorithms=$kex -oCiphers=$cipher"
|
2015-10-23 02:22:01 +00:00
|
|
|
min=2048
|
|
|
|
max=8192
|
|
|
|
groupsz="$min<$bits<$max"
|
2014-02-27 23:21:26 +00:00
|
|
|
verbose "$tid bits $bits $kex $cipher"
|
|
|
|
${SSH} ${opts} $@ -vvv -F ${OBJ}/ssh_proxy somehost true
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
fail "ssh failed ($@)"
|
|
|
|
fi
|
|
|
|
# check what we request
|
|
|
|
grep "SSH2_MSG_KEX_DH_GEX_REQUEST($groupsz) sent" ${LOG} >/dev/null
|
|
|
|
if [ $? != 0 ]; then
|
2023-03-02 08:14:52 +00:00
|
|
|
got="`egrep 'SSH2_MSG_KEX_DH_GEX_REQUEST(.*) sent' ${LOG}`"
|
|
|
|
fail "$tid unexpected GEX sizes, expected $groupsz, got '$got'"
|
2014-02-27 23:21:26 +00:00
|
|
|
fi
|
2019-09-27 05:25:12 +00:00
|
|
|
# check what we got.
|
2019-10-06 11:49:50 +00:00
|
|
|
gotbits="`awk 'BEGIN{FS="/"}/bits set:/{print $2}' ${LOG} |
|
|
|
|
head -1 | tr -d '\r\n'`"
|
2019-09-27 05:25:12 +00:00
|
|
|
trace "expected '$bits' got '$gotbits'"
|
|
|
|
if [ -z "$gotbits" ] || [ "$gotbits" -lt "$bits" ]; then
|
2014-02-27 23:21:26 +00:00
|
|
|
fatal "$tid expected $bits bit group, got $gotbits"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
check()
|
|
|
|
{
|
|
|
|
bits="$1"; shift
|
|
|
|
|
|
|
|
for c in $@; do
|
|
|
|
for k in $kexs; do
|
|
|
|
ssh_test_dhgex $bits $c $k
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2019-09-27 05:25:12 +00:00
|
|
|
check 3072 3des-cbc # 112 bits.
|
2014-02-27 23:21:26 +00:00
|
|
|
check 3072 `${SSH} -Q cipher | grep 128`
|
|
|
|
check 7680 `${SSH} -Q cipher | grep 192`
|
|
|
|
check 8192 `${SSH} -Q cipher | grep 256`
|
2020-12-21 22:48:41 +00:00
|
|
|
check 8192 chacha20-poly1305@openssh.com
|