blob: 57fca4a32e94ff5575d5332f447d78cee84c070f [file] [log] [blame]
Damien Milleredb1af52014-05-15 15:07:53 +10001# $OpenBSD: dhgex.sh,v 1.2 2014/04/21 22:15:37 djm Exp $
Damien Millerb8439232014-02-28 10:21:26 +11002# Placed in the Public Domain.
3
4tid="dhgex"
5
6LOG=${TEST_SSH_LOGFILE}
7rm -f ${LOG}
Damien Milleredb1af52014-05-15 15:07:53 +10008cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
Damien Millerb8439232014-02-28 10:21:26 +11009
10kexs=`${SSH} -Q kex | grep diffie-hellman-group-exchange`
11
12ssh_test_dhgex()
13{
14 bits="$1"; shift
15 cipher="$1"; shift
16 kex="$1"; shift
17
Damien Milleredb1af52014-05-15 15:07:53 +100018 cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
19 echo "KexAlgorithms=$kex" >> $OBJ/sshd_proxy
20 echo "Ciphers=$cipher" >> $OBJ/sshd_proxy
Damien Millerb8439232014-02-28 10:21:26 +110021 rm -f ${LOG}
22 opts="-oKexAlgorithms=$kex -oCiphers=$cipher"
23 groupsz="1024<$bits<8192"
24 verbose "$tid bits $bits $kex $cipher"
25 ${SSH} ${opts} $@ -vvv -F ${OBJ}/ssh_proxy somehost true
26 if [ $? -ne 0 ]; then
27 fail "ssh failed ($@)"
28 fi
29 # check what we request
30 grep "SSH2_MSG_KEX_DH_GEX_REQUEST($groupsz) sent" ${LOG} >/dev/null
31 if [ $? != 0 ]; then
32 got=`egrep "SSH2_MSG_KEX_DH_GEX_REQUEST(.*) sent" ${LOG}`
33 fail "$tid unexpected GEX sizes, expected $groupsz, got $got"
34 fi
35 # check what we got (depends on contents of system moduli file)
36 gotbits="`awk '/bits set:/{print $4}' ${LOG} | head -1 | cut -f2 -d/`"
37 if [ "$gotbits" -lt "$bits" ]; then
38 fatal "$tid expected $bits bit group, got $gotbits"
39 fi
40}
41
42check()
43{
44 bits="$1"; shift
45
46 for c in $@; do
47 for k in $kexs; do
48 ssh_test_dhgex $bits $c $k
49 done
50 done
51}
52
53#check 2048 3des-cbc
54check 3072 `${SSH} -Q cipher | grep 128`
55check 3072 arcfour blowfish-cbc
56check 7680 `${SSH} -Q cipher | grep 192`
57check 8192 `${SSH} -Q cipher | grep 256`
58check 8192 rijndael-cbc@lysator.liu.se chacha20-poly1305@openssh.com