xref: /freebsd/crypto/openssh/regress/cipher-speed.sh (revision 1323ec571215a77ddd21294f0871979d5ad6b992)
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
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 -e '/transferred/s/.*secs (\(.* bytes.sec\).*/\1/p' \
19	    -e '/copied/s/.*s, \(.* MB.s\).*/\1/p'
20}
21
22tries="1 2"
23
24for c in `${SSH} -Q cipher`; do n=0; for m in `${SSH} -Q mac`; do
25	trace "cipher $c mac $m"
26	for x in $tries; do
27		printf "%-60s" "$c/$m:"
28		( ${SSH} -o 'compression no' \
29			-F $OBJ/ssh_proxy -m $m -c $c somehost \
30			exec sh -c \'"dd of=/dev/null obs=32k"\' \
31		< ${DATA} ) 2>&1 | getbytes
32
33		if [ $? -ne 0 ]; then
34			fail "ssh failed with mac $m cipher $c"
35		fi
36	done
37	# No point trying all MACs for AEAD ciphers since they are ignored.
38	if ${SSH} -Q cipher-auth | grep "^${c}\$" >/dev/null 2>&1 ; then
39		break
40	fi
41	n=`expr $n + 1`
42done; done
43