1# $OpenBSD: rekey.sh,v 1.8 2013/05/17 04:29:14 dtucker Exp $ 2# Placed in the Public Domain. 3 4tid="rekey" 5 6LOG=${TEST_SSH_LOGFILE} 7 8rm -f ${LOG} 9 10for s in 16 1k 128k 256k; do 11 verbose "client rekeylimit ${s}" 12 rm -f ${COPY} ${LOG} 13 cat $DATA | \ 14 ${SSH} -oCompression=no -oRekeyLimit=$s \ 15 -v -F $OBJ/ssh_proxy somehost "cat > ${COPY}" 16 if [ $? -ne 0 ]; then 17 fail "ssh failed" 18 fi 19 cmp $DATA ${COPY} || fail "corrupted copy" 20 n=`grep 'NEWKEYS sent' ${LOG} | wc -l` 21 n=`expr $n - 1` 22 trace "$n rekeying(s)" 23 if [ $n -lt 1 ]; then 24 fail "no rekeying occured" 25 fi 26done 27 28for s in 5 10; do 29 verbose "client rekeylimit default ${s}" 30 rm -f ${COPY} ${LOG} 31 cat $DATA | \ 32 ${SSH} -oCompression=no -oRekeyLimit="default $s" -F \ 33 $OBJ/ssh_proxy somehost "cat >${COPY};sleep $s;sleep 3" 34 if [ $? -ne 0 ]; then 35 fail "ssh failed" 36 fi 37 cmp $DATA ${COPY} || fail "corrupted copy" 38 n=`grep 'NEWKEYS sent' ${LOG} | wc -l` 39 n=`expr $n - 1` 40 trace "$n rekeying(s)" 41 if [ $n -lt 1 ]; then 42 fail "no rekeying occured" 43 fi 44done 45 46for s in 5 10; do 47 verbose "client rekeylimit default ${s} no data" 48 rm -f ${COPY} ${LOG} 49 ${SSH} -oCompression=no -oRekeyLimit="default $s" -F \ 50 $OBJ/ssh_proxy somehost "sleep $s;sleep 3" 51 if [ $? -ne 0 ]; then 52 fail "ssh failed" 53 fi 54 n=`grep 'NEWKEYS sent' ${LOG} | wc -l` 55 n=`expr $n - 1` 56 trace "$n rekeying(s)" 57 if [ $n -lt 1 ]; then 58 fail "no rekeying occured" 59 fi 60done 61 62echo "rekeylimit default 5" >>$OBJ/sshd_proxy 63for s in 5 10; do 64 verbose "server rekeylimit default ${s} no data" 65 rm -f ${COPY} ${LOG} 66 ${SSH} -oCompression=no -F $OBJ/ssh_proxy somehost "sleep $s;sleep 3" 67 if [ $? -ne 0 ]; then 68 fail "ssh failed" 69 fi 70 n=`grep 'NEWKEYS sent' ${LOG} | wc -l` 71 n=`expr $n - 1` 72 trace "$n rekeying(s)" 73 if [ $n -lt 1 ]; then 74 fail "no rekeying occured" 75 fi 76done 77 78verbose "rekeylimit parsing" 79for size in 16 1k 1K 1m 1M 1g 1G; do 80 for time in 1 1m 1M 1h 1H 1d 1D 1w 1W; do 81 case $size in 82 16) bytes=16 ;; 83 1k|1K) bytes=1024 ;; 84 1m|1M) bytes=1048576 ;; 85 1g|1G) bytes=1073741824 ;; 86 esac 87 case $time in 88 1) seconds=1 ;; 89 1m|1M) seconds=60 ;; 90 1h|1H) seconds=3600 ;; 91 1d|1D) seconds=86400 ;; 92 1w|1W) seconds=604800 ;; 93 esac 94 95 b=`$SUDO ${SSHD} -T -o "rekeylimit $size $time" -f $OBJ/sshd_proxy | \ 96 awk '/rekeylimit/{print $2}'` 97 s=`$SUDO ${SSHD} -T -o "rekeylimit $size $time" -f $OBJ/sshd_proxy | \ 98 awk '/rekeylimit/{print $3}'` 99 100 if [ "$bytes" != "$b" ]; then 101 fatal "rekeylimit size: expected $bytes got $b" 102 fi 103 if [ "$seconds" != "$s" ]; then 104 fatal "rekeylimit time: expected $time got $s" 105 fi 106 done 107done 108 109rm -f ${COPY} ${DATA} 110