xref: /openbsd/regress/usr.bin/ssh/cipher-speed.sh (revision 5af055cd)
1#	$OpenBSD: cipher-speed.sh,v 1.13 2015/03/24 20:22:17 markus 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"
12
13for c in `${SSH} -Q cipher`; do n=0; for m in `${SSH} -Q mac`; do
14	trace "proto 2 cipher $c mac $m"
15	for x in $tries; do
16		printf "$c/$m:\t"
17		( ${SSH} -o 'compression no' \
18			-F $OBJ/ssh_proxy -2 -m $m -c $c somehost \
19			exec sh -c \'"dd of=/dev/null obs=32k"\' \
20		< ${DATA} ) 2>&1 | getbytes
21
22		if [ $? -ne 0 ]; then
23			fail "ssh -2 failed with mac $m cipher $c"
24		fi
25	done
26	# No point trying all MACs for AEAD ciphers since they are ignored.
27	if ${SSH} -Q cipher-auth | grep "^${c}\$" >/dev/null 2>&1 ; then
28		break
29	fi
30	n=$(($n + 1))
31done; done
32
33if ssh_version 1; then
34	ciphers="3des blowfish"
35else
36	ciphers=""
37fi
38for c in $ciphers; do
39	trace "proto 1 cipher $c"
40	for x in $tries; do
41		printf "$c:\t"
42		( ${SSH} -o 'compression no' \
43			-F $OBJ/ssh_proxy -1 -c $c somehost \
44			exec sh -c \'"dd of=/dev/null obs=32k"\' \
45		< ${DATA} ) 2>&1 | getbytes
46		if [ $? -ne 0 ]; then
47			fail "ssh -1 failed with cipher $c"
48		fi
49	done
50done
51