cryptoput.sh 1002 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. SCRIPT_PATH=${0%/*}
  3. if [ "$0" != "$SCRIPT_PATH" ] && [ "$SCRIPT_PATH" != "" ]; then
  4. cd "$SCRIPT_PATH/.."
  5. fi
  6. DAEMONFILEPATH="../../daemon/build/files"
  7. if [ $# -eq 1 ];
  8. then
  9. DAEMONFILEPATH="$1"
  10. fi
  11. echo "am in directory $PWD"
  12. echo "using file path $DAEMONFILEPATH"
  13. ./ccats-cli --batch test/cryptoput.txt
  14. if [ ! -f test/cryptoput.txt.out ];
  15. then
  16. echo "running of batch file failed"
  17. exit 1;
  18. fi
  19. if [ ! -f $DAEMONFILEPATH/samplefile.txt ];
  20. then
  21. echo "couldnt find file on server"
  22. echo "STDOUT is :"
  23. cat test/cryptoput.txt.out
  24. echo "STDERR is :"
  25. cat test/cryptoput.txt.err
  26. exit 1;
  27. fi
  28. test/cryptotest_gcm 0 test/samplekey1.bin $DAEMONFILEPATH/samplefile.txt samplefile.txt
  29. CRYPTORES=$?
  30. diff samplefile.txt test/samplefile.txt
  31. DIFFRES=$?
  32. rm $DAEMONFILEPATH/samplefile.txt
  33. rm samplefile.txt
  34. if [ $CRYPTORES -ne 0 ];
  35. then
  36. echo "decryption failed: $CRYPTORES"
  37. exit 1;
  38. fi
  39. if [ $DIFFRES -ne 0 ];
  40. then
  41. echo "files are not equal after decryption: $DIFFRES"
  42. exit 1;
  43. fi
  44. exit 0;