t_lpback.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #! /bin/sh
  2. #
  3. # t_lpback.sh - script to test OpenVPN's crypto loopback
  4. # Copyright (C) 2005 Matthias Andree
  5. # Copyright (C) 2014 Steffan Karger
  6. #
  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.
  11. #
  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.
  16. #
  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.
  21. set -eu
  22. top_builddir="${top_builddir:-..}"
  23. trap "rm -f key.$$ log.$$ ; trap 0 ; exit 77" 1 2 15
  24. trap "rm -f key.$$ log.$$ ; exit 1" 0 3
  25. # Get list of supported ciphers from openvpn --show-ciphers output
  26. CIPHERS=$(${top_builddir}/src/openvpn/openvpn --show-ciphers | \
  27. sed -e '/The following/,/^$/d' -e s'/ .*//' -e '/^[[:space:]]*$/d')
  28. # SK, 2014-06-04: currently the DES-EDE3-CFB1 implementation of OpenSSL is
  29. # broken (see http://rt.openssl.org/Ticket/Display.html?id=2867), so exclude
  30. # that cipher from this test.
  31. # GD, 2014-07-06 so is DES-CFB1
  32. # GD, 2014-07-06 do not test RC5-* either (fails on NetBSD w/o libcrypto_rc5)
  33. CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)' )
  34. # Also test cipher 'none'
  35. CIPHERS=${CIPHERS}$(printf "\nnone")
  36. "${top_builddir}/src/openvpn/openvpn" --genkey --secret key.$$
  37. set +e
  38. e=0
  39. for cipher in ${CIPHERS}
  40. do
  41. echo -n "Testing cipher ${cipher}... "
  42. ( "${top_builddir}/src/openvpn/openvpn" --test-crypto --secret key.$$ --cipher ${cipher} ) >log.$$ 2>&1
  43. if [ $? != 0 ] ; then
  44. echo "FAILED"
  45. cat log.$$
  46. e=1
  47. else
  48. echo "OK"
  49. fi
  50. done
  51. rm key.$$ log.$$
  52. trap 0
  53. exit $e