markus@openbsd.org | dad2b18 | 2015-03-03 22:35:19 +0000 | [diff] [blame^] | 1 | # $OpenBSD: cipher-speed.sh,v 1.12 2015/03/03 22:35:19 markus Exp $ |
Damien Miller | 7b1877c | 2006-07-24 15:31:41 +1000 | [diff] [blame] | 2 | # Placed in the Public Domain. |
| 3 | |
| 4 | tid="cipher speed" |
| 5 | |
| 6 | getbytes () |
| 7 | { |
Darren Tucker | fe10a28 | 2013-03-12 11:19:40 +1100 | [diff] [blame] | 8 | sed -n -e '/transferred/s/.*secs (\(.* bytes.sec\).*/\1/p' \ |
| 9 | -e '/copied/s/.*s, \(.* MB.s\).*/\1/p' |
Damien Miller | 7b1877c | 2006-07-24 15:31:41 +1000 | [diff] [blame] | 10 | } |
| 11 | |
| 12 | tries="1 2" |
Damien Miller | 7b1877c | 2006-07-24 15:31:41 +1000 | [diff] [blame] | 13 | |
Darren Tucker | a955041 | 2013-11-07 15:21:19 +1100 | [diff] [blame] | 14 | for c in `${SSH} -Q cipher`; do n=0; for m in `${SSH} -Q mac`; do |
Damien Miller | 7b1877c | 2006-07-24 15:31:41 +1000 | [diff] [blame] | 15 | trace "proto 2 cipher $c mac $m" |
| 16 | for x in $tries; do |
Darren Tucker | fe10a28 | 2013-03-12 11:19:40 +1100 | [diff] [blame] | 17 | printf "%-60s" "$c/$m:" |
Damien Miller | 7b1877c | 2006-07-24 15:31:41 +1000 | [diff] [blame] | 18 | ( ${SSH} -o 'compression no' \ |
| 19 | -F $OBJ/ssh_proxy -2 -m $m -c $c somehost \ |
| 20 | exec sh -c \'"dd of=/dev/null obs=32k"\' \ |
| 21 | < ${DATA} ) 2>&1 | getbytes |
| 22 | |
| 23 | if [ $? -ne 0 ]; then |
| 24 | fail "ssh -2 failed with mac $m cipher $c" |
| 25 | fi |
| 26 | done |
Damien Miller | 8a073cf | 2013-11-21 14:26:18 +1100 | [diff] [blame] | 27 | # No point trying all MACs for AEAD ciphers since they are ignored. |
| 28 | if ssh -Q cipher-auth | grep "^${c}\$" >/dev/null 2>&1 ; then |
| 29 | break |
| 30 | fi |
Tim Rice | c08b3ef | 2013-02-19 11:53:29 -0800 | [diff] [blame] | 31 | n=`expr $n + 1` |
Damien Miller | 7b1877c | 2006-07-24 15:31:41 +1000 | [diff] [blame] | 32 | done; done |
| 33 | |
markus@openbsd.org | dad2b18 | 2015-03-03 22:35:19 +0000 | [diff] [blame^] | 34 | if ssh_version 1; then |
| 35 | ciphers="3des blowfish" |
| 36 | else |
| 37 | ciphers="" |
| 38 | fi |
Damien Miller | 7b1877c | 2006-07-24 15:31:41 +1000 | [diff] [blame] | 39 | for c in $ciphers; do |
| 40 | trace "proto 1 cipher $c" |
| 41 | for x in $tries; do |
Darren Tucker | fe10a28 | 2013-03-12 11:19:40 +1100 | [diff] [blame] | 42 | printf "%-60s" "$c:" |
Damien Miller | 7b1877c | 2006-07-24 15:31:41 +1000 | [diff] [blame] | 43 | ( ${SSH} -o 'compression no' \ |
| 44 | -F $OBJ/ssh_proxy -1 -c $c somehost \ |
| 45 | exec sh -c \'"dd of=/dev/null obs=32k"\' \ |
| 46 | < ${DATA} ) 2>&1 | getbytes |
| 47 | if [ $? -ne 0 ]; then |
| 48 | fail "ssh -1 failed with cipher $c" |
| 49 | fi |
| 50 | done |
| 51 | done |