1# $OpenBSD: cipher-speed.sh,v 1.9 2013/05/17 04:29:14 dtucker 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 14ciphers="aes128-cbc 3des-cbc blowfish-cbc cast128-cbc 15 arcfour128 arcfour256 arcfour 16 aes192-cbc aes256-cbc rijndael-cbc@lysator.liu.se 17 aes128-ctr aes192-ctr aes256-ctr" 18config_defined OPENSSL_HAVE_EVPGCM && \ 19 ciphers="$ciphers aes128-gcm@openssh.com aes256-gcm@openssh.com" 20macs="hmac-sha1 hmac-md5 umac-64@openssh.com umac-128@openssh.com 21 hmac-sha1-96 hmac-md5-96" 22config_defined HAVE_EVP_SHA256 && \ 23 macs="$macs hmac-sha2-256 hmac-sha2-512" 24 25for c in $ciphers; do n=0; for m in $macs; do 26 trace "proto 2 cipher $c mac $m" 27 for x in $tries; do 28 printf "%-60s" "$c/$m:" 29 ( ${SSH} -o 'compression no' \ 30 -F $OBJ/ssh_proxy -2 -m $m -c $c somehost \ 31 exec sh -c \'"dd of=/dev/null obs=32k"\' \ 32 < ${DATA} ) 2>&1 | getbytes 33 34 if [ $? -ne 0 ]; then 35 fail "ssh -2 failed with mac $m cipher $c" 36 fi 37 done 38 # No point trying all MACs for GCM since they are ignored. 39 case $c in 40 aes*-gcm@openssh.com) test $n -gt 0 && break;; 41 esac 42 n=`expr $n + 1` 43done; done 44 45ciphers="3des blowfish" 46for c in $ciphers; do 47 trace "proto 1 cipher $c" 48 for x in $tries; do 49 printf "%-60s" "$c:" 50 ( ${SSH} -o 'compression no' \ 51 -F $OBJ/ssh_proxy -1 -c $c somehost \ 52 exec sh -c \'"dd of=/dev/null obs=32k"\' \ 53 < ${DATA} ) 2>&1 | getbytes 54 if [ $? -ne 0 ]; then 55 fail "ssh -1 failed with cipher $c" 56 fi 57 done 58done 59