dhgex.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # $OpenBSD: dhgex.sh,v 1.6 2019/10/06 11:49:50 dtucker Exp $
  2. # Placed in the Public Domain.
  3. tid="dhgex"
  4. LOG=${TEST_SSH_LOGFILE}
  5. rm -f ${LOG}
  6. cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
  7. kexs=$(${SSH} -Q kex | grep diffie-hellman-group-exchange)
  8. ssh_test_dhgex()
  9. {
  10. bits="$1"
  11. shift
  12. cipher="$1"
  13. shift
  14. kex="$1"
  15. shift
  16. cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
  17. echo "KexAlgorithms=$kex" >> $OBJ/sshd_proxy
  18. echo "Ciphers=$cipher" >> $OBJ/sshd_proxy
  19. rm -f ${LOG}
  20. opts="-oKexAlgorithms=$kex -oCiphers=$cipher"
  21. min=2048
  22. max=8192
  23. groupsz="$min<$bits<$max"
  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.
  36. gotbits="$(awk 'BEGIN{FS="/"}/bits set:/{print $2}' ${LOG} |
  37. head -1 | tr -d '\r\n')"
  38. trace "expected '$bits' got '$gotbits'"
  39. if [ -z "$gotbits" ] || [ "$gotbits" -lt "$bits" ]; then
  40. fatal "$tid expected $bits bit group, got $gotbits"
  41. fi
  42. }
  43. check()
  44. {
  45. bits="$1"
  46. shift
  47. for c in $@; do
  48. for k in $kexs; do
  49. ssh_test_dhgex $bits $c $k
  50. done
  51. done
  52. }
  53. check 3072 3des-cbc # 112 bits.
  54. check 3072 $(${SSH} -Q cipher | grep 128)
  55. check 7680 $(${SSH} -Q cipher | grep 192)
  56. check 8192 $(${SSH} -Q cipher | grep 256)
  57. check 8192 rijndael-cbc@lysator.liu.se chacha20-poly1305@openssh.com