]> git.scottworley.com Git - overonion/commitdiff
Automate hash test
authorScott Worley <scottworley@scottworley.com>
Mon, 23 Oct 2017 03:11:34 +0000 (20:11 -0700)
committerScott Worley <scottworley@scottworley.com>
Mon, 23 Oct 2017 03:11:34 +0000 (20:11 -0700)
overonion_test

index f4da9b40415da20b38da9b1b7e0ed26234cc35ca..85c782bf8455dcb2190a36c391d61158eaaeade6 100755 (executable)
@@ -1,13 +1,28 @@
 #!/bin/bash
 
-set -e
+test_data=$0
 
+# Verify hash mismatch is caught
 d=$(mktemp -d)
-test_data=$0
+./overonion-make-key --make_INSECURE_key "$d/key"
+cp "$d/key" "$d/key2"
+./overonion e "$d/key" < "$test_data" > "$d/encrypted"
+{ cat "$test_data"; echo tamper; } | ./overonion e "$d/key2" > "$d/encrypted2"
+if ./overonion d "$d/key" < "$d/encrypted2" > /dev/null;then
+  echo "Failed to detect tampering" >&2
+  exit 1
+fi
+rm -r "$d"
 
+
+
+# Verify normal operation
+set -e
+d=$(mktemp -d)
 ./overonion-make-key --make_INSECURE_key "$d/key"
 ./overonion e "$d/key" < "$test_data" > "$d/encrypted"
 ./overonion d "$d/key" < "$d/encrypted" > "$d/roundtripped"
 cmp --verbose "$d/roundtripped" "$test_data"
 rm -r "$d"
+
 echo PASS