Initial commit
[authen-passphrase-scrypt.git] / scrypt-1.2.1 / tests / 04-force-resources.sh
1 #!/bin/sh
2
3 ### Constants
4 c_valgrind_min=1
5 reference_file="${scriptdir}/test_scrypt.good"
6 longwait_encrypted_file="${out}/longwait.enc"
7 longwait_decrypted_file="${out}/longwait.txt"
8 longwait_failed_log="${out}/longwait-failed.log"
9
10 scenario_cmd() {
11 # Encrypt file which should take a long time to decrypt.
12 setup_check_variables
13 (
14 echo ${password} | ${c_valgrind_cmd} ${bindir}/scrypt \
15 enc -P -t 10 ${reference_file} \
16 ${longwait_encrypted_file}
17 echo $? > ${c_exitfile}
18 )
19
20 # Attempt to decrypt it with limited time. We want this
21 # command to fail, so we negate the normal return code.
22 setup_check_variables
23 (
24 echo ${password} | ${c_valgrind_cmd} ${bindir}/scrypt \
25 dec -P -t 1 ${longwait_encrypted_file} \
26 ${longwait_decrypted_file} \
27 2> ${longwait_failed_log}
28 test ! $? -eq 0
29 echo $? > ${c_exitfile}
30 )
31
32 # We should have received an error message.
33 setup_check_variables
34 if grep -q "scrypt: Decrypting file would take too much CPU time" \
35 ${longwait_failed_log}; then
36 echo "0"
37 else
38 echo "1"
39 fi > ${c_exitfile}
40
41 # Attempt to decrypt it with limited time, but force success.
42 setup_check_variables
43 (
44 echo ${password} | ${c_valgrind_cmd} ${bindir}/scrypt \
45 dec -P -t 1 -f ${longwait_encrypted_file} \
46 ${longwait_decrypted_file}
47 echo $? > ${c_exitfile}
48 )
49
50 # The decrypted reference file should match the reference.
51 setup_check_variables
52 if cmp -s ${longwait_decrypted_file} ${reference_file}; then
53 echo "0"
54 else
55 echo "1"
56 fi > ${c_exitfile}
57 }
This page took 0.021371 seconds and 4 git commands to generate.