sigtest.sh 837 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh
  2. if [ $# -eq 0 -o "-h" = "$1" -o "-help" = "$1" -o "--help" = "$1" ]; then
  3. cat <<EOHELP
  4. Usage: $0 <public> <signed manifest>
  5. sigtest.sh checks if a manifest is signed by the public key <public>. There is
  6. no output, success or failure is indicated via the return code.
  7. See also:
  8. * ecdsautils in https://github.com/tcatm/ecdsautils
  9. * http://gluon.readthedocs.org/en/latest/features/autoupdater.html
  10. EOHELP
  11. exit 1
  12. fi
  13. public="$1"
  14. manifest="$2"
  15. upper="$(mktemp)"
  16. lower="$(mktemp)"
  17. ret=1
  18. awk "BEGIN { sep=0 }
  19. /^---\$/ { sep=1; next }
  20. { if(sep==0) print > \"$upper\";
  21. else print > \"$lower\"}" \
  22. "$manifest"
  23. while read line
  24. do
  25. if ecdsaverify -s "$line" -p "$public" "$upper"; then
  26. ret=0
  27. break
  28. fi
  29. done < "$lower"
  30. rm -f "$upper" "$lower"
  31. exit $ret