Ticket #168: test-bug-168.sh

File test-bug-168.sh, 1.6 KB (added by ard, 11 years ago)

Script that automatically tests this bug for all cipher block modes.

Line 
1#!/bin/bash
2# This script automatically tests for OpenVPN bug #168.
3# It assumes that sample configurations and keys are installed at
4# /usr/share/doc/openvpn-*
5
6cd /usr/share/doc/openvpn-*
7TEMPFILE="/dev/shm/$$.$RANDOM"
8( for cipher in $(openvpn --show-ciphers | awk '{if (NF==0){ok=1; next}; if (ok) {print $1}}'); do
9        openvpn --test-crypto --secret sample-keys/ta.key --cipher $cipher >$TEMPFILE 2>&1
10        ECODE=$?
11        if [ $ECODE -eq 1 ]; then
12          if grep 'Assertion failed at crypto.c:161' $TEMPFILE >/dev/null; then
13                echo "BAD: Cipher $cipher does not work in Shared Secret mode."
14          else
15                echo "ERROR: There was some other problem while testing cipher $cipher in Shared Secret mode."
16          fi
17        else
18                if [ $ECODE -gt 0 ]; then
19                        echo "ERROR: Server exited with code $ECODE while testing cipher $cipher in Shared Secret mode."
20                else
21                        echo "GOOD: Cipher $cipher seems to work fine in Shared Secret mode."
22                fi
23        fi
24        openvpn --config sample-config-files/loopback-server --cipher $cipher >$TEMPFILE 2>&1 &
25        PID=$!
26        openvpn --config sample-config-files/loopback-client --cipher $cipher >/dev/null 2>&1
27        ECODE=$?
28        wait $PID
29        if [ $ECODE -eq 1 ]; then
30          if grep 'Assertion failed at crypto.c:161' $TEMPFILE >/dev/null; then
31                echo "BAD: Cipher $cipher does not work in TLS mode."
32          else
33                echo "ERROR: There was some other problem while testing cipher $cipher in TLS mode."
34          fi
35        else
36                if [ $ECODE -gt 0 ]; then
37                        echo "ERROR: Server exited with code $ECODE while testing cipher $cipher in TLS mode."
38                else
39                        echo "GOOD: Cipher $cipher seems to work fine in TLS mode."
40                fi
41        fi
42done
43rm -f $TEMPFILE
44) | sort
45
46