Hello,

In case it would be practical, here is a patch that adds a flexible option to gpgparticipants to choose the hash methods among the supported ones (md5, rmd160, sha1, sha224, sha256, sha384 and sha512, defaulting to md5 and sha256, the first one being considered as mandatory and the second one optional.

Example uses:
* MD5 and optionally SHA256:
      $ gpgparticipants input output date organizer title
* SHA256 only:
      $ gpgparticipants -a sha256 input output date organizer title
* RMD160 and optionally SHA256:
      $ gpgparticipants -a rmd160,sha256 input output date organizer title
* MD5 and optionally SHA1 and SHA256:
      $ gpgparticipants -a md5,sha1,sha256 input output date organizer title

My patch introduces requires getopt, from util-linux which is Essential anyway. It adds each hash to both the instructions and the hash patterns to be filled by hand. Oh, and while I was using getopt, I added -h and --help options too, and I moved the help to a dedicated function since it was used at several points.

The manpage would require some additions too. Personally, I would rewrite it in DocBook and compile it to troff…

Librement,

--
 ,--.
: /` )   Tanguy Ortolo      <xmpp:tan...@ortolo.eu>
| `-'    Debian Developer   <irc://irc.oftc.net/Tanguy>
 \_
Index: gpgparticipants/gpgparticipants
===================================================================
--- gpgparticipants/gpgparticipants	(révision 495)
+++ gpgparticipants/gpgparticipants	(copie de travail)
@@ -7,18 +7,52 @@
 # License: GPLv2 or later
 # Copyright Philippe Teuwen <phil a teuwen o org> 2008
 
-if [ $# -ne 5 ]; then
+usage()
+{
     cat <<EOF
-Usage: $0 input output datestring organizer title
-Or:    $0 -     output datestring organizer title
+Usage: $0 [-a|--algorithm HASHES] input output datestring organizer title
+Or:    $0 [-a|--algorithm HASHES] -     output datestring organizer title
        to read from STDIN
 Example:
        echo 9AD7E3DB 54C12701 |\\
        $0 - ksp-file.txt "20080222 1100" "My Name <my.n...@my.mail>" "my party 08"
 EOF
-    exit 0
+    exit $1
+}
+
+# Handle options and arguments
+##############################
+
+# Use getopt to validate and normalize options and arguments,
+# then reinject them as main arguments
+OPTS=$(getopt -o a:h -l algorithm:,help -n $0 -- "$@")
+if [ $? != 0 ]; then usage 1; fi
+eval set -- "$OPTS"
+
+# Default options
+algos="md5,sha256"
+
+# Parse options
+while [ "$1" != '--' ]
+do
+    case "$1"
+    in
+        -a|--algorithm) algos="$2"; shift 2;;
+        -h|--help) usage 0; shift;;
+        *) usage 1;;
+    esac
+done
+# Get rid of the '--' left before the arguments
+shift
+
+# Five arguments should remain
+if [ $# -ne 5 ]
+then
+    usage 1
 fi
 
+# Store options and arguments
+algos=$(echo "$algos" | tr ',' ' ')
 input="$1"
 [ "$input" = "-" ] && input="";
 output="$2"
@@ -35,30 +69,101 @@
 # Title
 printf "%*s\n\n" $(((72+$(echo "$title"|wc -c))/2)) "$title"
 # Header
+human_algos=$(echo "$algos" | tr '[:lower:]' '[:upper:]')
+first_human_algo="${human_algos%% *}"
+last_human_algo="${human_algos##* }"
+last_human_algos="${human_algos#* }"
+middle_human_algos="${last_human_algos% *}"
+if [ -n "$last_human_algos" -a -n "$middle_human_algos" ]
+then
+    human_algos="$first_human_algo and optionally $middle_human_algos and $last_human_algo checksums"
+elif [ -n "$last_human_algos" ]
+then
+    human_algos="$first_human_algo and optionally $last_human_algos checksums"
+else
+    human_algos="$first_human_algo checksum"
+fi
 cat <<EOF
                      List of Participants  (v 1.0)
 
 
 Here's what you have to do with this file:
 (1) Print this file to paper.
-(2) Compute this file's MD5 checksum and optionally also its SHA1 checksum.
-   gpg --print-md md5  $output  (or use md5sum)
-   gpg --print-md sha1 $output  (or use sha1sum)
+(2) Compute this file's $human_algos:
+EOF
+
+for algo in $algos
+do
+    cat <<EOF
+    gpg --print-md $algo  (or use ${algo}sum)
+EOF
+done
+
+cat <<EOF
 (3) Fill in the hash values on the printout.
 (4) Bring the printout, a pen, and proof of identity to the key signing party
     (and be on time!).
 
-MD5 Checksum:  __ __ __ __ __ __ __ __    __ __ __ __ __ __ __ __      [ ]
+EOF
 
+for algo in $algos
+do
+    case "$algo"
+    in
+        md5) cat <<EOF
 
+MD5 Checksum:  __ __ __ __ __ __ __ __    __ __ __ __ __ __ __ __       [ ]
+EOF
+        ;;
+        sha1) cat <<EOF
 
-SHA1 Checksum: ____ ____ ____ ____ ____    ____ ____ ____ ____ ____    [ ]
+SHA1 Checksum: ____ ____ ____ ____ ____    ____ ____ ____ ____ ____     [ ]
+EOF
+        ;;
+        rmd160) cat <<EOF
 
+RMD160 Checksum: ____ ____ ____ ____ ____    ____ ____ ____ ____ ____   [ ]
+EOF
+        ;;
+        sha224) cat <<EOF
 
+SHA224 Checksum: ________   ________   ________   ________
 
+                 ________   ________   ________                         [ ]
+EOF
+        ;;
+        sha256) cat <<EOF
 
+SHA256 Checksum: ________   ________   ________   ________
+
+                 ________   ________   ________   ________              [ ]
 EOF
+        ;;
+        sha384) cat <<EOF
 
+SHA256 Checksum: ________   ________   ________   ________
+
+                 ________   ________   ________   ________
+
+                 ________   ________   ________   ________              [ ]
+EOF
+        ;;
+        sha512) cat <<EOF
+
+SHA512 Checksum: ________   ________   ________   ________
+
+                 ________   ________   ________   ________
+
+                 ________   ________   ________   ________
+
+                 ________   ________   ________   ________              [ ]
+EOF
+        ;;
+    esac
+done
+
+printf '\n\n'
+
 k=0;
 for i in $(cat $input); do
     k=$(($k+1));
Index: gpgsigs/gpgsigs
===================================================================
--- gpgsigs/gpgsigs	(révision 495)
+++ gpgsigs/gpgsigs	(copie de travail)
@@ -182,7 +182,7 @@
 		if ($latex and not $photocount) { # call once per key
 			my ($shortkey) = substr $key, -8;
 			system "rm -f $shortkey.[1-9]*.eps";
-			system "gpg --photo-viewer 'gpgsigs-eps-helper $shortkey' --list-options show-photos --list-key $key > /dev/null";
+			system "gpg --photo-viewer '/usr/share/signing-party/gpgsigs-eps-helper $shortkey' --list-options show-photos --list-key $key > /dev/null";
 			$photocount = 1;
 		}
 		my ($shortkey) = substr $key, -8;

Attachment: signature.asc
Description: Digital signature

Reply via email to