14f52dfbbSDag-Erling Smørgrav# $OpenBSD: cipher-speed.sh,v 1.14 2017/04/30 23:34:55 djm Exp $ 2ce3adf43SDag-Erling Smørgrav# Placed in the Public Domain. 3ce3adf43SDag-Erling Smørgrav 4ce3adf43SDag-Erling Smørgravtid="cipher speed" 5ce3adf43SDag-Erling Smørgrav 6*1323ec57SEd Maste# Enable all supported ciphers and macs. 7*1323ec57SEd Masteciphers=`${SSH} -Q Ciphers | tr '\n' , | sed 's/,$//'` 8*1323ec57SEd Mastemacs=`${SSH} -Q MACs | tr '\n' , | sed 's/,$//'` 9*1323ec57SEd Mastecat >>$OBJ/sshd_proxy <<EOD 10*1323ec57SEd MasteCiphers $ciphers 11*1323ec57SEd MasteMACs $macs 12*1323ec57SEd MasteEOD 13*1323ec57SEd Maste 14*1323ec57SEd Masteincrease_datafile_size 10000 # 10MB 15*1323ec57SEd Maste 16ce3adf43SDag-Erling Smørgravgetbytes () 17ce3adf43SDag-Erling Smørgrav{ 18ce3adf43SDag-Erling Smørgrav sed -n -e '/transferred/s/.*secs (\(.* bytes.sec\).*/\1/p' \ 19ce3adf43SDag-Erling Smørgrav -e '/copied/s/.*s, \(.* MB.s\).*/\1/p' 20ce3adf43SDag-Erling Smørgrav} 21ce3adf43SDag-Erling Smørgrav 22ce3adf43SDag-Erling Smørgravtries="1 2" 23ce3adf43SDag-Erling Smørgrav 24f7167e0eSDag-Erling Smørgravfor c in `${SSH} -Q cipher`; do n=0; for m in `${SSH} -Q mac`; do 254f52dfbbSDag-Erling Smørgrav trace "cipher $c mac $m" 26ce3adf43SDag-Erling Smørgrav for x in $tries; do 27ce3adf43SDag-Erling Smørgrav printf "%-60s" "$c/$m:" 28ce3adf43SDag-Erling Smørgrav ( ${SSH} -o 'compression no' \ 294f52dfbbSDag-Erling Smørgrav -F $OBJ/ssh_proxy -m $m -c $c somehost \ 30ce3adf43SDag-Erling Smørgrav exec sh -c \'"dd of=/dev/null obs=32k"\' \ 31ce3adf43SDag-Erling Smørgrav < ${DATA} ) 2>&1 | getbytes 32ce3adf43SDag-Erling Smørgrav 33ce3adf43SDag-Erling Smørgrav if [ $? -ne 0 ]; then 344f52dfbbSDag-Erling Smørgrav fail "ssh failed with mac $m cipher $c" 35ce3adf43SDag-Erling Smørgrav fi 36ce3adf43SDag-Erling Smørgrav done 37f7167e0eSDag-Erling Smørgrav # No point trying all MACs for AEAD ciphers since they are ignored. 38557f75e5SDag-Erling Smørgrav if ${SSH} -Q cipher-auth | grep "^${c}\$" >/dev/null 2>&1 ; then 39f7167e0eSDag-Erling Smørgrav break 40f7167e0eSDag-Erling Smørgrav fi 41ce3adf43SDag-Erling Smørgrav n=`expr $n + 1` 42ce3adf43SDag-Erling Smørgravdone; done 43