File: 09-explicit-params.sh

package info (click to toggle)
scrypt 1.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,368 kB
  • sloc: ansic: 5,763; sh: 5,504; makefile: 257
file content (66 lines) | stat: -rw-r--r-- 2,170 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh

### Constants
c_valgrind_min=1
reference_file="${scriptdir}/verify-strings/test_scrypt.good"
encrypted_file="${s_basename}-reference.enc"
stderr="${s_basename}-reference.stderr"
encrypted_file_bad="${s_basename}-reference-bad.enc"
stderr_bad="${s_basename}-reference-bad.stderr"

scenario_cmd() {
	# Encrypt with manually-specified N, r, p.
	setup_check "scrypt enc Nrp"
	echo "${password}" | ${c_valgrind_cmd} "${bindir}/scrypt"	\
	    enc -v --logN 12 -r 2 -p 3					\
	    --passphrase dev:stdin-once					\
	    "${reference_file}" "${encrypted_file}"			\
	    2> "${stderr}"
	echo $? > "${c_exitfile}"

	# Check that the options were used.
	setup_check "scrypt enc Nrp output N"
	grep -q "N = 4096" "${stderr}"
	echo $? > "${c_exitfile}"

	setup_check "scrypt enc Nrp output r"
	grep -q "r = 2" "${stderr}"
	echo $? > "${c_exitfile}"

	setup_check "scrypt enc Nrp output p"
	grep -q "p = 3" "${stderr}"
	echo $? > "${c_exitfile}"

	# Try to encrypt with badly-specified N, r, p; should fail.
	setup_check "scrypt enc Nrp bad"
	echo "${password}" | ${c_valgrind_cmd} "${bindir}/scrypt"	\
	    enc -v --logN 2 -r 0 -p 0					\
	    --passphrase dev:stdin-once					\
	    "${reference_file}" "${encrypted_file_bad}"			\
	    2> "${stderr_bad}"
	expected_exitcode 1 $? > "${c_exitfile}"

	# Check that we got an error.
	setup_check "scrypt enc Nrp bad output"
	grep -q "\--logN must be between 10 and 40 (inclusive)" "${stderr_bad}"
	echo $? > "${c_exitfile}"

	# Check that we can't partially set explicit parameters.
	setup_check "scrypt enc --logN only"
	${c_valgrind_cmd} "${bindir}/scrypt"				\
	    enc --logN 12 "${reference_file}" 2>&1 |			\
	    grep -q "If --logN is set, -r and -p must also be set"
	echo $? > "${c_exitfile}"

	setup_check "scrypt enc -r only"
	${c_valgrind_cmd} "${bindir}/scrypt"				\
	    enc -r 12 "${reference_file}" 2>&1 |			\
	    grep -q "If -r is set, --logN and -p must also be set"
	echo $? > "${c_exitfile}"

	setup_check "scrypt enc -p only"
	${c_valgrind_cmd} "${bindir}/scrypt"				\
	    enc -p 12 "${reference_file}" 2>&1 |			\
	    grep -q "If -p is set, --logN and -r must also be set"
	echo $? > "${c_exitfile}"
}