|
Packit Service |
4684c1 |
#!/bin/sh
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
# Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
|
Packit Service |
4684c1 |
#
|
|
Packit Service |
4684c1 |
# Author: Nikos Mavrogiannopoulos
|
|
Packit Service |
4684c1 |
#
|
|
Packit Service |
4684c1 |
# This file is part of GnuTLS.
|
|
Packit Service |
4684c1 |
#
|
|
Packit Service |
4684c1 |
# GnuTLS is free software; you can redistribute it and/or modify it
|
|
Packit Service |
4684c1 |
# under the terms of the GNU General Public License as published by the
|
|
Packit Service |
4684c1 |
# Free Software Foundation; either version 3 of the License, or (at
|
|
Packit Service |
4684c1 |
# your option) any later version.
|
|
Packit Service |
4684c1 |
#
|
|
Packit Service |
4684c1 |
# GnuTLS is distributed in the hope that it will be useful, but
|
|
Packit Service |
4684c1 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
4684c1 |
# General Public License for more details.
|
|
Packit Service |
4684c1 |
#
|
|
Packit Service |
4684c1 |
# You should have received a copy of the GNU Lesser General Public License
|
|
Packit Service |
4684c1 |
# along with this program. If not, see <https://www.gnu.org/licenses/>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
srcdir="${srcdir:-.}"
|
|
Packit Service |
4684c1 |
PSKTOOL="${PSKTOOL:-../src/psktool${EXEEXT}}"
|
|
Packit Service |
4684c1 |
TMPFILE=psktool.$$.tmp
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if ! test -x "${PSKTOOL}"; then
|
|
Packit Service |
4684c1 |
exit 77
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if test "${WINDIR}" != ""; then
|
|
Packit Service |
4684c1 |
exit 77
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if ! test -z "${VALGRIND}"; then
|
|
Packit Service |
4684c1 |
VALGRIND="${LIBTOOL:-libtool} --mode=execute ${VALGRIND} --error-exitcode=15"
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
. "${srcdir}/scripts/common.sh"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
echo "Checking PSK tool basic operations"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
# echo create a user and check whether a key is available
|
|
Packit Service |
4684c1 |
"${PSKTOOL}" -p ${TMPFILE} -u test
|
|
Packit Service |
4684c1 |
if test $? != 0;then
|
|
Packit Service |
4684c1 |
echo "password generation failed..."
|
|
Packit Service |
4684c1 |
exit 1
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
grep 'test:' ${TMPFILE} >/dev/null 2>&1
|
|
Packit Service |
4684c1 |
if test $? != 0;then
|
|
Packit Service |
4684c1 |
echo "could not find generated user..."
|
|
Packit Service |
4684c1 |
exit 1
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
KEY=$(cat ${TMPFILE} |cut -d ':' -f 2)
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if test "${#KEY}" != 64;then
|
|
Packit Service |
4684c1 |
echo "the generated key is not 256-bits"
|
|
Packit Service |
4684c1 |
exit 1
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
# Create second user and check whether both exist
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
"${PSKTOOL}" -p ${TMPFILE} -u user2
|
|
Packit Service |
4684c1 |
if test $? != 0;then
|
|
Packit Service |
4684c1 |
echo "password generation failed..."
|
|
Packit Service |
4684c1 |
exit 1
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
grep 'test:' ${TMPFILE} >/dev/null 2>&1
|
|
Packit Service |
4684c1 |
if test $? != 0;then
|
|
Packit Service |
4684c1 |
echo "could not find first generated user..."
|
|
Packit Service |
4684c1 |
exit 1
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
grep 'user2:' ${TMPFILE} >/dev/null 2>&1
|
|
Packit Service |
4684c1 |
if test $? != 0;then
|
|
Packit Service |
4684c1 |
echo "could not find second generated user..."
|
|
Packit Service |
4684c1 |
exit 1
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
rm -f $TMPFILE
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
exit 0
|