| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Test that the passphrase hashing seems to take long enough. |
| 4 |
|
| 5 |
cd "$(dirname "$0")" |
| 6 |
. common.sh |
| 7 |
|
| 8 |
dir="$MNT/dir" |
| 9 |
|
| 10 |
# Test encrypting 5 dirs with default of 1s. |
| 11 |
fscrypt setup --force --quiet |
| 12 |
start_time=$(date +%s) |
| 13 |
for i in $(seq 5); do |
| 14 |
rm -rf "$dir" |
| 15 |
mkdir "$dir" |
| 16 |
echo hunter2 | fscrypt encrypt --quiet --name="prot$i" "$dir" |
| 17 |
done |
| 18 |
end_time=$(date +%s) |
| 19 |
elapsed=$((end_time - start_time)) |
| 20 |
if (( elapsed <= 3 )); then |
| 21 |
_fail "Passphrase hashing was much faster than expected! (expected about 5 x 1 == 5s, got ${elapsed}s)" |
| 22 |
fi |
| 23 |
|
| 24 |
# Test encrypting 1 dir with difficulty overridden to 5s. |
| 25 |
fscrypt setup --force --quiet --time=5s |
| 26 |
start_time=$(date +%s) |
| 27 |
rm -rf "$dir" |
| 28 |
mkdir "$dir" |
| 29 |
echo hunter2 | fscrypt encrypt --quiet --name=prot6 "$dir" |
| 30 |
end_time=$(date +%s) |
| 31 |
elapsed=$((end_time - start_time)) |
| 32 |
if (( elapsed <= 3 )); then |
| 33 |
_fail "Passphrase hashing was much faster than expected! (expected about 5s, got ${elapsed}s)" |
| 34 |
fi |