Initial commit
[authen-passphrase-scrypt.git] / scrypt-1.2.1 / tests / 03-encrypt-decrypt-file.sh
CommitLineData
0c1f3509
MG
1#!/bin/sh
2
3### Constants
4c_valgrind_min=1
5reference_file="${scriptdir}/test_scrypt.good"
6encrypted_file="${out}/attempt.enc"
7decrypted_file="${out}/attempt.txt"
8
9scenario_cmd() {
10 # Encrypt a file.
11 setup_check_variables
12 (
13 echo ${password} | ${c_valgrind_cmd} ${bindir}/scrypt \
14 enc -P -t 1 ${reference_file} ${encrypted_file}
15 echo $? > ${c_exitfile}
16 )
17
18 # The encrypted file should be different from the original file.
19 # We cannot check against the "reference" encrypted file, because
20 # encrypted files include random salt. If successful, don't delete
21 # ${encrypted_file} yet; we need it for the next test.
22 setup_check_variables
23 if cmp -s ${encrypted_file} ${reference_file}; then
24 echo "1"
25 else
26 echo "0"
27 fi > ${c_exitfile}
28
29 # Decrypt the file we just encrypted.
30 setup_check_variables
31 (
32 echo ${password} | ${c_valgrind_cmd} ${bindir}/scrypt \
33 dec -P ${encrypted_file} ${decrypted_file}
34 echo $? > ${c_exitfile}
35 )
36
37 # The decrypted file should match the reference.
38 setup_check_variables
39 if cmp -s ${decrypted_file} ${reference_file}; then
40 echo "0"
41 else
42 echo "1"
43 fi > ${c_exitfile}
44}
This page took 0.011484 seconds and 4 git commands to generate.