1#!/bin/sh 2# aescrypt.sh 3# This shell validates the 'aescrypt' and 'aesget' encrypytion and decryption algorithms on various Unix/Linux platforms. 4# This script is to be run first on an i686 Linux box, and the results stored on cvs. 5# Then, when testing a Linux or Unix port on another platform, the same input files are copied to the platform to be tested. 6# Then, this script is to be run again, and the files compared. 7# If the files are the same, then the port was successful. 8### 1) Find out what platform we're running on. 9### 2) Encrypt the test file on this platform, using 'aescrypt', and the keyfile stored on cvs. 10### 3) Decrypt the encrypted test file, using 'aesget' and the keyfile stored on cvs. 11### 4) Compare the unencrypted file from the i686 Linux box, and the decrypted file on the platform being tested. 12### If they are the same, all is well. 13 14### 1) Find out what platform we're running on. 15echo "Deciding what platform we are on..." 16TRYOS=`uname` 17#if test $TRYOS == "UnixWare" 18if [ $TRYOS = "UnixWare" ] 19then 20 OS=`uname` 21 ARCH=`uname -m` 22else 23 OS=`uname | tr "/" "-"` 24 ARCH=`uname -m | tr "/" "-"` 25fi 26 27echo "We are running ${OS} on a ${ARCH} machine." 28 29### 2) Encrypt the test file on this platform, using 'aescrypt', and the keyfile stored on cvs. 30if [ -f "aescrypt.${OS}.${ARCH}.encrypted.src" ] # If the file already exists, remove it 31then 32 echo "Removing 'aescrypt.${OS}.${ARCH}.encrypted.src'..." 33 rm -f aescrypt.${OS}.${ARCH}.encrypted.src 34fi 35 36# Use the previously-generated 'aescrypt.Linux.i686.key' file to encrypt the test file. 37# First, check to make sure the "aescrypt" executable is in the current directory. 38if [ ! -f "aescrypt" ] 39then 40 if [ -f "/opt/brupro/bin/aescrypt" ] 41 then 42 cp -p /opt/brupro/bin/aescrypt . 43 else 44 echo "Could not find the 'aescrypt' executable. Aborting..." 45 exit 1 46 fi 47fi 48 49./aescrypt -k aescrypt.Linux.i686.key < aescrypt.Linux.i686.src > aescrypt.${OS}.${ARCH}.encrypted.src 50 51### 3) Decrypt the encrypted test file, using 'aesget' and the keyfile stored on cvs. 52if [ -f "aescrypt.${OS}.${ARCH}.decrypted.src" ] # If the file already exists, remove it 53then 54 echo "Removing 'aescrypt.${OS}.${ARCH}.decrypted.src'..." 55 rm -f aescrypt.${OS}.${ARCH}.decrypted.src 56fi 57 58# Use the previously-generated 'aescrypt.Linux.i686.key' file to decrypt the encrypted test file. 59# First, check to make sure the "aesget" executable is in the current directory. 60if [ ! -f "aesget" ] 61then 62 if [ -f "/opt/brupro/bin/aesget" ] 63 then 64 cp -p /opt/brupro/bin/aesget . 65 else 66 echo "Could not find the 'aesget' executable. Aborting..." 67 exit 1 68 fi 69fi 70 71./aesget -k aescrypt.Linux.i686.key < aescrypt.${OS}.${ARCH}.encrypted.src > aescrypt.${OS}.${ARCH}.decrypted.src 72 73### 4) Compare the unencrypted file from the i686 Linux box, and the decrypted file on the platform being tested. 74### If they are the same, all is well. 75diff aescrypt.Linux.i686.src aescrypt.${OS}.${ARCH}.decrypted.src 76#if test $? = 0 77if test $? -eq 0 78then 79 echo "The test file 'aescrypt.Linux.i686.src' decrypted correctly on this $OS/$ARCH platform." 80else 81 echo "ERROR!!! The file 'aescrypt.Linux.i686.src' did NOT decrypt correctly on this $OS/$ARCH platform." 82fi 83