aboutsummaryrefslogtreecommitdiff
path: root/cli-tests/t_passphrase_hashing.sh
blob: a67dd7c1ed952a60ab9dfd7d839bbf81e5847b76 (plain)
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
#!/bin/bash

# Test that the passphrase hashing seems to take long enough.

cd "$(dirname "$0")"
. common.sh

dir="$MNT/dir"

# Test encrypting 5 dirs with default of 1s.
fscrypt setup --force --quiet
start_time=$(date +%s)
for i in $(seq 5); do
	rm -rf "$dir"
	mkdir "$dir"
	echo hunter2 | fscrypt encrypt --quiet --name="prot$i" "$dir"
done
end_time=$(date +%s)
elapsed=$((end_time - start_time))
if (( elapsed <= 3 )); then
	_fail "Passphrase hashing was much faster than expected! (expected about 5 x 1 == 5s, got ${elapsed}s)"
fi

# Test encrypting 1 dir with difficulty overridden to 5s.
fscrypt setup --force --quiet --time=5s
start_time=$(date +%s)
rm -rf "$dir"
mkdir "$dir"
echo hunter2 | fscrypt encrypt --quiet --name=prot6 "$dir"
end_time=$(date +%s)
elapsed=$((end_time - start_time))
if (( elapsed <= 3 )); then
	_fail "Passphrase hashing was much faster than expected! (expected about 5s, got ${elapsed}s)"
fi