#!/bin/sh
#basic test implementation, see test.sh for more details
PGPPATH=.
export PGPPATH
rm -f testfile*
cp README testfile.pro
cp README testfile.out
while ( cmp testfile.pro testfile.out ); do 
    rm -f pubring.pgp secring.pgp
    ./keygen -n 512 -s secring.pgp -o pubring.pgp
    ./minipgp -i testfile.pro -o testfile.c1 -u 0
    ./minipgp -i testfile.pro -o testfile.d1 -l testfile.out 
    ./minipgp -i testfile.d1  -o testfile.con -p TestPass -c
    ./minipgp -i testfile.con -o testfile.e1 -p TestPass 
    ./minipgp -i testfile.e1  -o testfile.out -x
    if cmp testfile.pro testfile.out; then echo convencr ok; else exit 0; fi
    cat testfile.c1 testfile.d1 >testfile.f1
    ./minipgp -i testfile.f1  -o testfile.z1 -z
    ./minipgp -i testfile.z1  -o testfile.a1 -e 0
    ./minipgp -i testfile.a1  -o testfile.asc -a MESSAGE 

#cp testfile.asc testfile.out
##loop to do dearmor, decrypt, decompress as necessary
#while(    ./minipgp -i testfile.out -o testfile.sgn ); do
#    cp testfile.sgn testfile.out
#done

    ./minipgp -i testfile.asc -o testfile.g1
    ./minipgp -i testfile.g1  -o testfile.h1
    ./minipgp -i testfile.h1  -o testfile.sgn

#extract from literal
    ./minipgp -i testfile.sgn -o testfile.out -x

    if ./minipgp -i testfile.sgn -d ; then true; else echo Bad Sig; exit 0; fi
    if cmp testfile.pro testfile.out; then echo decrypt ok; else exit 0; fi
done

