#!/bin/sh

testsrc=Makefile.ssl
test=./p

cat $testsrc >$test;

echo cat
../apps/ssleay enc < $test > $test.cipher
../apps/ssleay enc < $test.cipher >$test.clear
cmp $test $test.clear
if [ $? != 0 ]
then
	exit 1
else
	/bin/rm $test.cipher $test.clear
fi
echo base64
../apps/ssleay enc -a -e < $test > $test.cipher
../apps/ssleay enc -a -d < $test.cipher >$test.clear
cmp $test $test.clear
if [ $? != 0 ]
then
	exit 1
else
	/bin/rm $test.cipher $test.clear
fi

for i in rc4 \
	des-cfb des-ede-cfb des-ede3-cfb \
	des-ofb des-ede-ofb des-ede3-ofb \
	des-ecb des-ede des-ede3 \
	des-cbc des-ede-cbc des-ede3-cbc \
	idea-ecb idea-cfb idea-ofb idea-cbc \
	rc2-ecb rc2-cfb rc2-ofb rc2-cbc 
do
	echo $i
	../apps/ssleay $i -e -k test < $test > $test.$i.cipher
	../apps/ssleay $i -d -k test < $test.$i.cipher >$test.$i.clear
	cmp $test $test.$i.clear
	if [ $? != 0 ]
	then
		exit 1
	else
		/bin/rm $test.$i.cipher $test.$i.clear
	fi

	echo $i base64
	../apps/ssleay $i -a -e -k test < $test > $test.$i.cipher
	../apps/ssleay $i -a -d -k test < $test.$i.cipher >$test.$i.clear
	cmp $test $test.$i.clear
	if [ $? != 0 ]
	then
		exit 1
	else
		/bin/rm $test.$i.cipher $test.$i.clear
	fi
done
rm -f $test
