make-signature.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. if test "$1" = "" ; then
  3. echo "I need a package as an argument."
  4. exit 1
  5. fi
  6. PACKAGEFILE=$1
  7. if test ! -f "$PACKAGEFILE" ; then
  8. echo "$PACKAGEFILE is not a file."
  9. exit 1
  10. fi
  11. DIGESTNAME=sha256
  12. DIGESTOUTPUT=`gpg --print-md $DIGESTNAME $PACKAGEFILE`
  13. RAWDIGEST=`gpg --print-md $DIGESTNAME $PACKAGEFILE | sed -e 's/^[^ ]*: //' `
  14. # These regexes are a little fragile, but I think they work for us.
  15. VERSION=`echo $PACKAGEFILE | sed -e 's/^[a-z\-]*//' -e 's/\.[\.a-z]*$//' `
  16. PACKAGE=`echo $PACKAGEFILE | sed -e 's/-[0-9].*//'`
  17. SIGFILE_UNSIGNED="$PACKAGE-$VERSION-signature"
  18. SIGNATUREFILE="$SIGFILE_UNSIGNED.asc"
  19. cat >$SIGFILE_UNSIGNED <<EOF
  20. This is the signature file for "$PACKAGEFILE",
  21. which contains version "$VERSION" of "$PACKAGE".
  22. Here's how to check this signature.
  23. 1) Make sure that this is really a signature file, and not a forgery,
  24. with:
  25. "gpg --verify $SIGNATUREFILE"
  26. The key should be one of the keys that signs the Tor release; the
  27. official Tor website has more information on those.
  28. If this step fails, then either you are missing the correct key, or
  29. this signature file was not really signed by a Tor packager.
  30. Beware!
  31. 2) Make sure that the package you wanted is indeed "$PACKAGE", and that
  32. its version you wanted is indeed "$VERSION". If you wanted a
  33. different package, or a different version, this signature file is
  34. not the right one!
  35. 3) Now that you're sure you have the right signature file, make sure
  36. that you got the right package. Check its $DIGESTNAME digest with
  37. "gpg --print-md $DIGESTNAME $PACKAGEFILE"
  38. The output should match this, exactly:
  39. $DIGESTOUTPUT
  40. Make sure that every part of the output matches: don't just check the
  41. first few characters. If the digest does not match, you do not have
  42. the right package file. It could even be a forgery.
  43. Frequentlty asked questions:
  44. Q: Why not just sign the package file, like you used to do?
  45. A: GPG signatures authenticate file contents, but not file names. If
  46. somebody gave you a renamed file with a matching renamed signature
  47. file, the signature would still be given as "valid".
  48. --
  49. FILENAME: $PACKAGEFILE
  50. PACKAGE: $PACKAGE
  51. VERSION: $VERSION
  52. DIGESTALG: $DIGESTNAME
  53. DIGEST: $RAWDIGEST
  54. EOF
  55. gpg --clearsign $SIGFILE_UNSIGNED