#! /bin/sh
#:
if test $# -eq 0
then
     echo "error, usage: grading_script.sh <login> "
     exit 0;
fi

# set the random file environmnet.
echo '>>>' grading .... $1
cp /home/cs772/randomfile .
RANDFILE=randomfile
export RANDFILE 
#
unzip $1_all.zip
#
# get the sym passwd
openssl enc -base64  -d -in passwd.base64 -out passwd.cipher
openssl rsautl -decrypt -inkey   /home/cs772/cs772_rsakeys/cs772_rsaprivatekey.pem -in passwd.cipher -out  passwd.txt
echo '>>>' $1 passwd is .....  :  `cat passwd.txt`
#
#decrypt a1.zip
openssl enc -des3  -d -salt -a -out a1.zip -in a1_zip.base64
#
#verify the signature of the MD of a1.zip
openssl enc -base64  -d -in a1_zip_mdsignature.base64 -out a1_zip_mdsignature
openssl dgst -sha1 -verify /home/cs772/public_html/fall04/public_keys/$1_rsapublickey.pem -signature  a1_zip_mdsignature a1.zip
#
unzip a1.zip

