06-decrypt-fail.sh 982 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/sh
  2. ### Constants
  3. c_valgrind_min=1
  4. non_encoded_file="${scriptdir}/06-decrypt-fail.sh"
  5. non_encoded_file_stderr="${s_basename}-stderr.txt"
  6. non_encoded_file_output="${s_basename}-nonfile.txt"
  7. scenario_cmd() {
  8. # Attempt to decrypt a non-scrypt-encoded file.
  9. # We want this command to fail with 1.
  10. setup_check_variables "scrypt dec non-scrypt"
  11. (
  12. echo "" | ${c_valgrind_cmd} "${bindir}/scrypt" \
  13. dec -P "${non_encoded_file}" \
  14. "${non_encoded_file_output}" \
  15. 2>> "${non_encoded_file_stderr}"
  16. expected_exitcode 1 $? > "${c_exitfile}"
  17. )
  18. # We should have received an error message.
  19. setup_check_variables "scrypt dec non-scrypt error"
  20. grep -q "scrypt: Input is not valid scrypt-encrypted block" \
  21. "${non_encoded_file_stderr}"
  22. echo "$?" > "${c_exitfile}"
  23. # We should not have created a file.
  24. setup_check_variables "scrypt dec non-scrypt no file"
  25. if [ -e "${non_encoded_file_output}" ]; then
  26. echo "1"
  27. else
  28. echo "0"
  29. fi > "${c_exitfile}"
  30. }