09-explicit-params.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh
  2. ### Constants
  3. c_valgrind_min=1
  4. reference_file="${scriptdir}/verify-strings/test_scrypt.good"
  5. encrypted_file="${s_basename}-reference.enc"
  6. stderr="${s_basename}-reference.stderr"
  7. encrypted_file_bad="${s_basename}-reference-bad.enc"
  8. stderr_bad="${s_basename}-reference-bad.stderr"
  9. scenario_cmd() {
  10. # Encrypt with manually-specified N, r, p.
  11. setup_check "scrypt enc Nrp"
  12. echo "${password}" | ${c_valgrind_cmd} "${bindir}/scrypt" \
  13. enc -v --logN 12 -r 2 -p 3 \
  14. --passphrase dev:stdin-once \
  15. "${reference_file}" "${encrypted_file}" \
  16. 2> "${stderr}"
  17. echo $? > "${c_exitfile}"
  18. # Check that the options were used.
  19. setup_check "scrypt enc Nrp output N"
  20. grep -q "N = 4096" "${stderr}"
  21. echo $? > "${c_exitfile}"
  22. setup_check "scrypt enc Nrp output r"
  23. grep -q "r = 2" "${stderr}"
  24. echo $? > "${c_exitfile}"
  25. setup_check "scrypt enc Nrp output p"
  26. grep -q "p = 3" "${stderr}"
  27. echo $? > "${c_exitfile}"
  28. # Try to encrypt with badly-specified N, r, p; should fail.
  29. setup_check "scrypt enc Nrp bad"
  30. echo "${password}" | ${c_valgrind_cmd} "${bindir}/scrypt" \
  31. enc -v --logN 2 -r 0 -p 0 \
  32. --passphrase dev:stdin-once \
  33. "${reference_file}" "${encrypted_file_bad}" \
  34. 2> "${stderr_bad}"
  35. expected_exitcode 1 $? > "${c_exitfile}"
  36. # Check that we got an error.
  37. setup_check "scrypt enc Nrp bad output"
  38. grep -q "\--logN must be between 10 and 40 (inclusive)" "${stderr_bad}"
  39. echo $? > "${c_exitfile}"
  40. # Check that we can't partially set explicit parameters.
  41. setup_check "scrypt enc --logN only"
  42. ${c_valgrind_cmd} "${bindir}/scrypt" \
  43. enc --logN 12 "${reference_file}" 2>&1 | \
  44. grep -q "If --logN is set, -r and -p must also be set"
  45. echo $? > "${c_exitfile}"
  46. setup_check "scrypt enc -r only"
  47. ${c_valgrind_cmd} "${bindir}/scrypt" \
  48. enc -r 12 "${reference_file}" 2>&1 | \
  49. grep -q "If -r is set, --logN and -p must also be set"
  50. echo $? > "${c_exitfile}"
  51. setup_check "scrypt enc -p only"
  52. ${c_valgrind_cmd} "${bindir}/scrypt" \
  53. enc -p 12 "${reference_file}" 2>&1 | \
  54. grep -q "If -p is set, --logN and -r must also be set"
  55. echo $? > "${c_exitfile}"
  56. }