OpenVPN: update to 2.3.5
[tomato.git] / release / src / router / openvpn / tests / t_lpback.sh
blob8f88ad926a297c8c50115d5b9bf20deaddfc0269
1 #! /bin/sh
3 # t_lpback.sh - script to test OpenVPN's crypto loopback
4 # Copyright (C) 2005 Matthias Andree
5 # Copyright (C) 2014 Steffan Karger
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 # 02110-1301, USA.
22 set -eu
23 top_builddir="${top_builddir:-..}"
24 trap "rm -f key.$$ log.$$ ; trap 0 ; exit 77" 1 2 15
25 trap "rm -f key.$$ log.$$ ; exit 1" 0 3
27 # Get list of supported ciphers from openvpn --show-ciphers output
28 CIPHERS=$(${top_builddir}/src/openvpn/openvpn --show-ciphers | \
29 sed -e '1,/^$/d' -e s'/ .*//' -e '/^\s*$/d' | sort)
31 # SK, 2014-06-04: currently the DES-EDE3-CFB1 implementation of OpenSSL is
32 # broken (see http://rt.openssl.org/Ticket/Display.html?id=2867), so exclude
33 # that cipher from this test.
34 # GD, 2014-07-06 so is DES-CFB1
35 # GD, 2014-07-06 do not test RC5-* either (fails on NetBSD w/o libcrypto_rc5)
36 CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)' )
38 "${top_builddir}/src/openvpn/openvpn" --genkey --secret key.$$
39 set +e
41 e=0
42 for cipher in ${CIPHERS}
44 echo -n "Testing cipher ${cipher}... "
45 ( "${top_builddir}/src/openvpn/openvpn" --test-crypto --secret key.$$ --cipher ${cipher} ) >log.$$ 2>&1
46 if [ $? != 0 ] ; then
47 echo "FAILED"
48 cat log.$$
49 e=1
50 else
51 echo "OK"
53 done
55 rm key.$$ log.$$
56 trap 0
57 exit $e