diff options
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/mencrypt | 25 | ||||
-rwxr-xr-x | contrib/msign | 22 |
2 files changed, 47 insertions, 0 deletions
diff --git a/contrib/mencrypt b/contrib/mencrypt new file mode 100755 index 0000000..12ef28c --- /dev/null +++ b/contrib/mencrypt @@ -0,0 +1,25 @@ +#!/bin/sh +# mencrypt PLAINMSG - generate a PGP/MIME signed and encrypted message + +[ -f "$1" ] || exit 1 + +IFS=' +' +FLAGS=$(mhdr -d -A -h from:to:cc:bcc: "$1" |sort -u |sed 's/^/--recipient=/') + +TMPD=$(mktemp -d -t mencrypt.XXXXXX) +trap "rm -rf '$TMPD'" INT TERM EXIT + +awk '/^$/,0' "$1" | + mmime | + gpg --armor --encrypt --sign $FLAGS -o $TMPD/msg.asc || + exit $? + +printf 'Version: 1\n' >$TMPD/version + +{ + sed '/^$/q' "$1" + printf '#application/pgp-encrypted %s/version\n' "$TMPD" + printf '#application/octet-stream %s/msg.asc\n' "$TMPD" +} | + mmime -t 'multipart/encrypted; protocol="application/pgp-encrypted"' diff --git a/contrib/msign b/contrib/msign new file mode 100755 index 0000000..9add078 --- /dev/null +++ b/contrib/msign @@ -0,0 +1,22 @@ +#!/bin/sh +# msign PLAINMSG - generate a PGP/MIME signed message + +[ -f "$1" ] || exit 1 + +IFS=' +' + +TMPD=$(mktemp -d -t msign.XXXXXX) +trap "rm -rf '$TMPD'" INT TERM EXIT + +awk '/^$/,0' "$1" | mmime | sed 's/$/ /' >"$TMPD"/content +gpg --armor --detach-sign -o "$TMPD"/signature.asc "$TMPD"/content || + exit $? + +{ + sed '/^$/q' "$1" + printf '#mblaze/raw %s/content\n' "$TMPD" + printf '#application/pgp-signature %s/signature.asc\n' "$TMPD" +} | + mmime -t 'multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"' + |