cipher-speed.sh 849 B

123456789101112131415161718192021222324252627282930313233343536
  1. # $OpenBSD: cipher-speed.sh,v 1.14 2017/04/30 23:34:55 djm Exp $
  2. # Placed in the Public Domain.
  3. tid="cipher speed"
  4. getbytes()
  5. {
  6. sed -n -e '/transferred/s/.*secs (\(.* bytes.sec\).*/\1/p' \
  7. -e '/copied/s/.*s, \(.* MB.s\).*/\1/p'
  8. }
  9. tries="1 2"
  10. for c in $(${SSH} -Q cipher); do
  11. n=0
  12. for m in $(${SSH} -Q mac); do
  13. trace "cipher $c mac $m"
  14. for x in $tries; do
  15. printf "%-60s" "$c/$m:"
  16. (${SSH} -o 'compression no' \
  17. -F $OBJ/ssh_proxy -m $m -c $c somehost \
  18. exec sh -c \'"dd of=/dev/null obs=32k"\' \
  19. < ${DATA}) 2>&1 | getbytes
  20. if [ $? -ne 0 ]; then
  21. fail "ssh failed with mac $m cipher $c"
  22. fi
  23. done
  24. # No point trying all MACs for AEAD ciphers since they are ignored.
  25. if ${SSH} -Q cipher-auth | grep "^${c}\$" > /dev/null 2>&1; then
  26. break
  27. fi
  28. n=$(expr $n + 1)
  29. done
  30. done