#!/bin/sh
######################################################################
##   Copyright (C) International Business Machines  Corp., 2003
##
##   This program is free software;  you can redistribute it and/or modify
##   it under the terms of the GNU General Public License as published by
##   the Free Software Foundation; either version 2 of the License, or
##   (at your option) any later version.
##
##   This program is distributed in the hope that it will be useful,
##   but WITHOUT ANY WARRANTY;  without even the implied warranty of
##   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
##   the GNU General Public License for more details.
##
##   You should have received a copy of the GNU General Public License
##   along with this program;  if not, write to the Free Software
##   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
##
##
##  FILE   : openssl01.sh
##
##  PURPOSE: To test the basic protocol functionality of OpenSSL.
##
##  HISTORY:
##    06/03 Originated by Michael A. Halcrow <mike@halcrow.us>
##
######################################################################

RETURNVAL=0

echo OpenSSL Tests from the OpenSSL package

if test "${LTPROOT+set}" = set;
then 
    /bin/true
else 
    LTPROOT=$PWD
fi;

echo "LTPROOT=[${LTPROOT}]";

echo Setting up test account\(s\)... 
${LTPROOT}/bin/setup_accounts.sh
if [ $? = 0 ];
then
	/bin/true;
else
	echo "Error setting up accounts";
	exit 1
fi;

echo Checking system date...
${LTPROOT}/bin/setup_date.sh
if [ $? = 0 ];
then
	/bin/true;
else
	echo "Error with system date";
	exit 1
fi;

echo Testing DES...
${LTPROOT}/bin/destest
RESULT=$?
echo -n "DES: "
if [ $RESULT = 0 ];
then
    echo "PASS";
else
    echo "FAIL";
    RETURNVAL=1
fi;

echo Testing RSA...
${LTPROOT}/bin/rsa_test
RESULT=$?
echo -n "RSA: "
if [ $RESULT = 0 ];
then
    echo "PASS";
else
    echo "FAIL";
    RETURNVAL=1
fi;

echo Testing DSA...
${LTPROOT}/bin/dsatest
RESULT=$?
echo -n "DSA: "
if [ $RESULT = 0 ];
then
    echo "PASS";
else
    echo "FAIL";
    RETURNVAL=1
fi;

echo Testing DH...
${LTPROOT}/bin/dhtest
RESULT=$?
echo -n "DH: "
if [ $RESULT = 0 ];
then
    echo "PASS";
else
    echo "FAIL";
    RETURNVAL=1
fi;

echo Testing SHA1...
${LTPROOT}/bin/sha1test
RESULT=$?
echo -n "SHA1: "
if [ $RESULT = 0 ];
then
    echo "PASS";
else
    echo "FAIL";
    RETURNVAL=1
fi;

echo Testing random number generation...
${LTPROOT}/bin/randtest
RESULT=$?
echo -n "RANDTEST: "
if [ $RESULT = 0 ];
then
    echo "PASS";
else
    echo "FAIL";
    RETURNVAL=1
fi;

echo Testing RC4...
${LTPROOT}/bin/rc4test
RESULT=$?
echo -n "RC4TEST: "
if [ $RESULT = 0 ];
then
    echo "PASS";
else
    echo "FAIL";
    RETURNVAL=1
fi;

echo Testing SSL protocol with RSA certs \(client/server via stunnel\)...
${LTPROOT}/bin/stunnel_rsa.sh
RESULT=$?
echo -n "SSL protocol (RSA): "
if [ $RESULT = 0 ];
then
    echo "PASS";
else
    echo "FAIL";
    RETURNVAL=1
fi;

# Uncomment when stunnel supports DSA...
#echo Testing SSL protocol with DSA certs \(client/server via stunnel\)...
#${LTPROOT}/bin/stunnel_dsa.sh
#RESULT=$?
#echo -n "SSL protocol (DSA): "
#if [ $RESULT = 0 ];
#then
#    echo "PASS";
#else
#    echo "FAIL";
#    RETURNVAL=1
#fi;

echo Testing password authentication...
${LTPROOT}/bin/password_auth.sh
RESULT=$?
echo -n "Password auth: "
if [ $RESULT = 0 ];
then
    echo "PASS";
else
    echo "FAIL";
    RETURNVAL=1
fi;

echo Removing temporary test accounts...
${LTPROOT}/bin/delete_accounts.sh

echo Restoring system date...
${LTPROOT}/bin/restore_date.sh
if [ $? = 0 ];
then
        /bin/true;
else
        echo "Error restoring system date";
        exit 1
fi;

exit ${RETURNVAL}





