1#	$OpenBSD: cipher-speed.sh,v 1.14 2017/04/30 23:34:55 djm Exp $
2#	Placed in the Public Domain.
3
4tid="cipher speed"
5
6getbytes ()
7{
8	sed -n -e '/transferred/s/.*secs (\(.* bytes.sec\).*/\1/p' \
9	    -e '/copied/s/.*s, \(.* MB.s\).*/\1/p'
10}
11
12tries="1 2"
13
14for c in `${SSH} -Q cipher`; do n=0; for m in `${SSH} -Q mac`; do
15	trace "cipher $c mac $m"
16	for x in $tries; do
17		printf "%-60s" "$c/$m:"
18		( ${SSH} -o 'compression no' \
19			-F $OBJ/ssh_proxy -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 failed with mac $m cipher $c"
25		fi
26	done
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
31	n=`expr $n + 1`
32done; done
33