1#	$OpenBSD: cipher-speed.sh,v 1.15 2022/01/21 02:54:41 dtucker Exp $
2#	Placed in the Public Domain.
3
4tid="cipher speed"
5
6# Enable all supported ciphers and macs.
7ciphers=`${SSH} -Q Ciphers | tr '\n' , | sed 's/,$//'`
8macs=`${SSH} -Q MACs | tr '\n' , | sed 's/,$//'`
9cat >>$OBJ/sshd_proxy <<EOD
10Ciphers $ciphers
11MACs $macs
12EOD
13
14increase_datafile_size 10000 # 10MB
15
16getbytes ()
17{
18	sed -n '/transferred/s/.*secs (\(.* bytes.sec\).*/\1/p'
19}
20
21tries="1 2"
22
23for c in `${SSH} -Q cipher`; do n=0; for m in `${SSH} -Q mac`; do
24	trace "cipher $c mac $m"
25	for x in $tries; do
26		printf "$c/$m:\t"
27		( ${SSH} -o 'compression no' \
28			-F $OBJ/ssh_proxy -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 failed with mac $m cipher $c"
34		fi
35	done
36	# No point trying all MACs for AEAD ciphers since they are ignored.
37	if ${SSH} -Q cipher-auth | grep "^${c}\$" >/dev/null 2>&1 ; then
38		break
39	fi
40	n=$(($n + 1))
41done; done
42
43