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