1#	$OpenBSD: cipher-speed.sh,v 1.4 2011/08/02 01:23:41 djm Exp $
2#	Placed in the Public Domain.
3
4tid="cipher speed"
5
6getbytes ()
7{
8	sed -n '/transferred/s/.*secs (\(.* bytes.sec\).*/\1/p'
9}
10
11tries="1 2"
12DATA=/bin/ls
13DATA=/bsd
14
15ciphers="aes128-cbc 3des-cbc blowfish-cbc cast128-cbc 
16	arcfour128 arcfour256 arcfour 
17	aes192-cbc aes256-cbc rijndael-cbc@lysator.liu.se
18	aes128-ctr aes192-ctr aes256-ctr"
19macs="hmac-sha1 hmac-md5 umac-64@openssh.com hmac-sha1-96 hmac-md5-96"
20config_defined HAVE_EVP_SHA256 &&
21    macs="$macs hmac-sha2-256 hmac-sha2-256-96 hmac-sha2-512 hmac-sha2-512-96"
22
23for c in $ciphers; do for m in $macs; do
24	trace "proto 2 cipher $c mac $m"
25	for x in $tries; do
26		echon "$c/$m:\t"
27		( ${SSH} -o 'compression no' \
28			-F $OBJ/ssh_proxy -2 -m $m -c $c somehost \
29			exec sh -c \'"dd of=/dev/null obs=32k"\' \
30		< ${DATA} ) 2>&1 | getbytes
31
32		if [ $? -ne 0 ]; then
33			fail "ssh -2 failed with mac $m cipher $c"
34		fi
35	done
36done; done
37
38ciphers="3des blowfish"
39for c in $ciphers; do
40	trace "proto 1 cipher $c"
41	for x in $tries; do
42		echon "$c:\t"
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
51done
52