1*4d3fc8b0SEd Maste# $OpenBSD: dhgex.sh,v 1.8 2023/03/02 08:14:52 dtucker Exp $ 2b83788ffSDag-Erling Smørgrav# Placed in the Public Domain. 3b83788ffSDag-Erling Smørgrav 4b83788ffSDag-Erling Smørgravtid="dhgex" 5b83788ffSDag-Erling Smørgrav 6b83788ffSDag-Erling SmørgravLOG=${TEST_SSH_LOGFILE} 7b83788ffSDag-Erling Smørgravrm -f ${LOG} 8a0ee8cc6SDag-Erling Smørgravcp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak 9b83788ffSDag-Erling Smørgrav 10b83788ffSDag-Erling Smørgravkexs=`${SSH} -Q kex | grep diffie-hellman-group-exchange` 11b83788ffSDag-Erling Smørgrav 12b83788ffSDag-Erling Smørgravssh_test_dhgex() 13b83788ffSDag-Erling Smørgrav{ 14b83788ffSDag-Erling Smørgrav bits="$1"; shift 15b83788ffSDag-Erling Smørgrav cipher="$1"; shift 16b83788ffSDag-Erling Smørgrav kex="$1"; shift 17b83788ffSDag-Erling Smørgrav 18a0ee8cc6SDag-Erling Smørgrav cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy 19a0ee8cc6SDag-Erling Smørgrav echo "KexAlgorithms=$kex" >> $OBJ/sshd_proxy 20a0ee8cc6SDag-Erling Smørgrav echo "Ciphers=$cipher" >> $OBJ/sshd_proxy 21b83788ffSDag-Erling Smørgrav rm -f ${LOG} 22b83788ffSDag-Erling Smørgrav opts="-oKexAlgorithms=$kex -oCiphers=$cipher" 23acc1a9efSDag-Erling Smørgrav min=2048 24acc1a9efSDag-Erling Smørgrav max=8192 25acc1a9efSDag-Erling Smørgrav groupsz="$min<$bits<$max" 26b83788ffSDag-Erling Smørgrav verbose "$tid bits $bits $kex $cipher" 27b83788ffSDag-Erling Smørgrav ${SSH} ${opts} $@ -vvv -F ${OBJ}/ssh_proxy somehost true 28b83788ffSDag-Erling Smørgrav if [ $? -ne 0 ]; then 29b83788ffSDag-Erling Smørgrav fail "ssh failed ($@)" 30b83788ffSDag-Erling Smørgrav fi 31b83788ffSDag-Erling Smørgrav # check what we request 32b83788ffSDag-Erling Smørgrav grep "SSH2_MSG_KEX_DH_GEX_REQUEST($groupsz) sent" ${LOG} >/dev/null 33b83788ffSDag-Erling Smørgrav if [ $? != 0 ]; then 34*4d3fc8b0SEd Maste got="`egrep 'SSH2_MSG_KEX_DH_GEX_REQUEST(.*) sent' ${LOG}`" 35*4d3fc8b0SEd Maste fail "$tid unexpected GEX sizes, expected $groupsz, got '$got'" 36b83788ffSDag-Erling Smørgrav fi 3719261079SEd Maste # check what we got. 3819261079SEd Maste gotbits="`awk 'BEGIN{FS="/"}/bits set:/{print $2}' ${LOG} | 3919261079SEd Maste head -1 | tr -d '\r\n'`" 4019261079SEd Maste trace "expected '$bits' got '$gotbits'" 4119261079SEd Maste if [ -z "$gotbits" ] || [ "$gotbits" -lt "$bits" ]; then 42b83788ffSDag-Erling Smørgrav fatal "$tid expected $bits bit group, got $gotbits" 43b83788ffSDag-Erling Smørgrav fi 44b83788ffSDag-Erling Smørgrav} 45b83788ffSDag-Erling Smørgrav 46b83788ffSDag-Erling Smørgravcheck() 47b83788ffSDag-Erling Smørgrav{ 48b83788ffSDag-Erling Smørgrav bits="$1"; shift 49b83788ffSDag-Erling Smørgrav 50b83788ffSDag-Erling Smørgrav for c in $@; do 51b83788ffSDag-Erling Smørgrav for k in $kexs; do 52b83788ffSDag-Erling Smørgrav ssh_test_dhgex $bits $c $k 53b83788ffSDag-Erling Smørgrav done 54b83788ffSDag-Erling Smørgrav done 55b83788ffSDag-Erling Smørgrav} 56b83788ffSDag-Erling Smørgrav 5719261079SEd Mastecheck 3072 3des-cbc # 112 bits. 58b83788ffSDag-Erling Smørgravcheck 3072 `${SSH} -Q cipher | grep 128` 59b83788ffSDag-Erling Smørgravcheck 7680 `${SSH} -Q cipher | grep 192` 60b83788ffSDag-Erling Smørgravcheck 8192 `${SSH} -Q cipher | grep 256` 6119261079SEd Mastecheck 8192 chacha20-poly1305@openssh.com 62