diff options
author | David Phillips <david@sighup.nz> | 2017-06-27 17:20:50 +1200 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2017-06-27 17:22:00 +1200 |
commit | f4629a55ed53acffb29208403e15be9a279b7a9f (patch) | |
tree | 8a0185226aaaa89fa05e9eace36d29f8f977d828 /test.sh | |
parent | 587dcdadb0056929c5fc0bd06cf1651a1d886166 (diff) | |
download | sand-leek-f4629a55ed53acffb29208403e15be9a279b7a9f.tar.xz |
Add basic sanity check script
Diffstat (limited to 'test.sh')
-rwxr-xr-x | test.sh | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -0,0 +1,34 @@ +#!/bin/sh + +set -e + +key="$(mktemp)" +stderr="$(mktemp)" + +# Four character search should be a < 1 second CPU burst for CI runner +./sand-leek -s site > $key 2>$stderr + +found="$(grep Found $stderr | cut -d ' ' -f 2)" + +echo "sand-leek says it found $found..." + +# Trick adapted to py3 from https://swehack.org/viewtopic.php?f=37&p=6978 +real="$( \ + openssl rsa -in $key -pubout -outform DER \ + | tail -c +23 \ + | shasum \ + | head -c 20 \ + | python -c "import base64,sys,codecs; print(base64.b32encode(codecs.decode(sys.stdin.readline().strip('\n'), 'hex')).decode().lower())").onion" + + +echo "Key analysis shows it's for ${real}" + +if [ "$found" == "$real" ] ; then + echo "It's a match, I'm happy" + rm $key + rm $stderr + exit 0 +else + echo "Error: No match" + exit 1 +fi |