#!/bin/bash

# Compile all the JAVA programs

msgdgst1="MD5.java"
msgdgst2="SHA.java"
sign1="RSASignGen.java"
sign2="DSASignGen.java"
verify1="RSASignVeri.java"
verify2="DSASignVeri.java"

javac $msgdgst1
javac $msgdgst2
javac $sign1
javac $sign2
javac $verify1
javac $verify2

# ******************************************
# PART - I
# ******************************************

# For the text "Kanwal Rekhi School of Information Technology, IIT Bombay" do
# the following...

# 1). Calculate the digest of a message (Both SHA-1 and MD-5).

echo "			    THIS IS THE OUTPUT FILE    " > output
echo "			    =======================    " >> output	
echo " " >> output
echo "  Part 1)." >> output

echo " Algo 		 File_Size	Time			KeySize" >> output
echo "------------------------------------------------------------------" >> output

java MD5 kresit_file >> output

java SHA kresit_file >> output

# 2). Compute the RSA and DSA Signatures of a message(with keysize say 1024).

java RSASignGen 1024 kresit_file >> output
java DSASignGen 1024 kresit_file >> output

# 3). Verify the RSA and DSA Signatures.

java RSASignVeri kresit_file.rsa_public_key kresit_file.rsa_sign kresit_file >> output
java DSASignVeri kresit_file.dsa_public_key kresit_file.dsa_sign kresit_file >> output

# ******************************************
# PART - II
# ******************************************

#  Time estimation for the message digest as a function of 
#  message size, key size  and the algorithm.

echo "----------------------------------------------------------------" >> output
echo "  Part 2)." >> output
echo "----------------------------------------------------------------" >> output

for i in 1 2 3 4 5 6 7 8
do
    java MD5 input_file.$i >> output
done

for i in 1 2 3 4 5 6 7 8
do
    java SHA input_file.$i >> output
done

echo "----------------------------------------------------------------" >> output
echo "  Part 2)." >> output
echo "----------------------------------------------------------------" >> output

temp=512
while [ $temp -le 2048 ]
do
#    echo $temp :	
    java RSASignGen `expr $temp` kresit_file >> output
    java RSASignVeri kresit_file.rsa_public_key kresit_file.rsa_sign kresit_file >> output 
    temp=`expr $temp + 128`
done


echo "----------------------------------------------------------------" >> output

for i in 1 2 3 4 5 6 7 8
do
    java RSASignGen 1024 input_file.$i >> output

    java RSASignVeri input_file.$i.rsa_public_key input_file.$i.rsa_sign input_file.$i >> output 
done

echo "----------------------------------------------------------------" >> output

temp=512
while [ $temp -le 1024 ]
do
 #   echo $temp :	
    java DSASignGen `expr $temp` kresit_file >> output
    java DSASignVeri kresit_file.dsa_public_key kresit_file.dsa_sign kresit_file >> output 
    temp=`expr $temp + 64`
done


echo "----------------------------------------------------------------" >> output

for i in 1 2 3 4 5 6 7 8
do
    java DSASignGen 1024 input_file.$i >> output
    java DSASignVeri input_file.$i.dsa_public_key input_file.$i.dsa_sign input_file.$i >> output 
done

echo "----------------------------------------------------------------" >> output



