hash.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #parse argument
  2. architecture=$1
  3. permutation=$2
  4. matrix_decompressed_file=$3
  5. matrix_comp_file=$4
  6. output_dir=$5
  7. lorem_ipsum_file=$6
  8. if [ $permutation -eq 0 ] ; then
  9. permutation_str=""
  10. else
  11. permutation_str=" -no-permutation-key "
  12. fi
  13. # make hash
  14. str="
  15. xrnlib-cli \
  16. --decoding-conf -compiled-param -no-password \
  17. --encoding-conf -compiled-param -no-password \
  18. --sequence-conf -xmatrix $matrix_decompressed_file \
  19. --permutation-conf -arch $architecture $permutation_str \
  20. --make-hash -plain-text $lorem_ipsum_file -hash $output_dir/hash.xf
  21. "
  22. echo ""; echo $str; echo ""
  23. eval $str
  24. # check hash
  25. str="
  26. xrnlib-cli \
  27. --decoding-conf -compiled-param -no-password \
  28. --encoding-conf -compiled-param -no-password \
  29. --arithmetic-conf -hash $output_dir/hash.xf \
  30. --sequence-conf -xmatrix $matrix_decompressed_file \
  31. --permutation-conf -arch $architecture \
  32. --logging-conf -lib-info-log $output_dir/lib_info_log_file.xf \
  33. --check-hash -plain-text $lorem_ipsum_file
  34. "
  35. echo ""; echo $str; echo ""
  36. eval $str
  37. str="
  38. if ! [ -s $output_dir/lib_info_log_file.xf ]; then echo FAIL ; exit ; fi ; \
  39. if grep -q FAIL \"$output_dir/lib_info_log_file.xf\" ; then echo FAIL ; exit ; fi
  40. "
  41. echo ""; echo $str; echo ""
  42. eval $str
  43. # generate wrong file
  44. str="
  45. cp $lorem_ipsum_file $output_dir/wrong_lorem_ipsum ; echo "a" >> $output_dir/wrong_lorem_ipsum ;
  46. "
  47. echo ""; echo $str; echo ""
  48. eval $str
  49. # check hash
  50. str="
  51. xrnlib-cli \
  52. --decoding-conf -compiled-param -no-password \
  53. --encoding-conf -compiled-param -no-password \
  54. --arithmetic-conf -hash $output_dir/hash.xf \
  55. --sequence-conf -xmatrix $matrix_decompressed_file \
  56. --permutation-conf -arch $architecture \
  57. --logging-conf -lib-info-log $output_dir/wrong_lib_info_log_file.xf \
  58. --check-hash -plain-text $output_dir/wrong_lorem_ipsum
  59. "
  60. echo ""; echo $str; echo ""
  61. eval $str
  62. str="
  63. if ! [ -s $output_dir/wrong_lib_info_log_file.xf ]; then echo FAIL ; exit ; fi ; \
  64. if grep -q PASS \"$output_dir/wrong_lib_info_log_file.xf\" ; then echo FAIL ; exit ; fi
  65. "
  66. echo ""; echo $str; echo ""
  67. eval $str