1 # $OpenBSD: integrity.sh,v 1.12 2013/11/21 03:18:51 djm Exp $
2 # Placed in the Public Domain.
6 # start at byte 2900 (i.e. after kex) and corrupt at different offsets
7 # XXX the test hangs if we modify the low bytes of the packet length
8 # XXX and ssh tries to read...
12 # The following are not MACs, but ciphers with integrated integrity. They are
13 # handled specially below.
14 macs="$macs `${SSH} -Q cipher-auth`"
16 # avoid DH group exchange as the extra traffic makes it harder to get the
17 # offset into the stream right.
18 echo "KexAlgorithms diffie-hellman-group14-sha1,diffie-hellman-group1-sha1" \
21 # sshd-command for proxy (see test-exec.sh)
22 cmd="$SUDO sh ${SRC}/sshd-log-wrapper.sh ${SSHD} ${TEST_SSHD_LOGFILE} -i -f $OBJ/sshd_proxy"
25 trace "test $tid: mac $m"
31 for off in `jot $tries $startoffset`; do
33 if [ $skip -gt 0 ]; then
34 # avoid modifying the high bytes of the length
37 # modify output from sshd at offset $off
38 pxy="proxycommand=$cmd | $OBJ/modpipe -wm xor:$off:1"
39 if ssh -Q cipher-auth | grep "^${m}\$" >/dev/null 2>&1 ; then
42 macopt="-m $m -c aes128-ctr"
44 verbose "test $tid: $m @$off"
45 ${SSH} $macopt -2F $OBJ/ssh_proxy -o "$pxy" \
46 -oServerAliveInterval=1 -oServerAliveCountMax=30 \
47 999.999.999.999 'printf "%4096s" " "' >/dev/null
49 fail "ssh -m $m succeeds with bit-flip at $off"
52 output=$(tail -2 $TEST_SSH_LOGFILE | egrep -v "^debug" | \
55 Bad?packet*) elen=`expr $elen + 1`; skip=3;;
56 Corrupted?MAC* | Decryption?integrity?check?failed*)
57 emac=`expr $emac + 1`; skip=0;;
58 padding*) epad=`expr $epad + 1`; skip=0;;
59 *) fail "unexpected error mac $m at $off";;
62 verbose "test $tid: $ecnt errors: mac $emac padding $epad length $elen"
63 if [ $emac -eq 0 ]; then
64 fail "$m: no mac errors"
66 expect=`expr $ecnt - $epad - $elen`
67 if [ $emac -ne $expect ]; then
68 fail "$m: expected $expect mac errors, got $emac"