Blame tests/psktool.sh

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