]> git.scottworley.com Git - overonion/blob - overonion_test
85c782bf8455dcb2190a36c391d61158eaaeade6
[overonion] / overonion_test
1 #!/bin/bash
2
3 test_data=$0
4
5 # Verify hash mismatch is caught
6 d=$(mktemp -d)
7 ./overonion-make-key --make_INSECURE_key "$d/key"
8 cp "$d/key" "$d/key2"
9 ./overonion e "$d/key" < "$test_data" > "$d/encrypted"
10 { cat "$test_data"; echo tamper; } | ./overonion e "$d/key2" > "$d/encrypted2"
11 if ./overonion d "$d/key" < "$d/encrypted2" > /dev/null;then
12 echo "Failed to detect tampering" >&2
13 exit 1
14 fi
15 rm -r "$d"
16
17
18
19 # Verify normal operation
20 set -e
21 d=$(mktemp -d)
22 ./overonion-make-key --make_INSECURE_key "$d/key"
23 ./overonion e "$d/key" < "$test_data" > "$d/encrypted"
24 ./overonion d "$d/key" < "$d/encrypted" > "$d/roundtripped"
25 cmp --verbose "$d/roundtripped" "$test_data"
26 rm -r "$d"
27
28 echo PASS