sign.sh 510 B

12345678910111213141516171819202122232425262728
  1. #!/bin/sh
  2. if [ $# -eq 0 -o "-h" = "$1" -o "-help" = "$1" -o "--help" = "$1" ]; then
  3. cat <<EOHELP
  4. Usage: $0 <secret> <manifest>
  5. EOHELP
  6. exit 1
  7. fi
  8. SECRET=$1
  9. manifest=$2
  10. upper=$(mktemp)
  11. lower=$(mktemp)
  12. awk "BEGIN { sep=0 }
  13. /^---\$/ { sep=1; next }
  14. { if(sep==0) print > \"$upper\";
  15. else print > \"$lower\"}" \
  16. $manifest
  17. ecdsasign $upper < $SECRET >> $lower
  18. cat $upper > $manifest
  19. echo --- >> $manifest
  20. cat $lower >> $manifest
  21. rm -f $upper $lower