summary refs log tree commit diff
path: root/contrib
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-05-26 23:31:06 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-05-26 23:31:06 +0200
commitb45b0560d748ff02f525665f590e5cd605f289d3 (patch)
tree9dcad162ab8eee76051444bf0e2befb8de0a5175 /contrib
parent122711840c3d103bbb5d9844c3af01ea555c606c (diff)
downloadmblaze-b45b0560d748ff02f525665f590e5cd605f289d3.tar.gz
mblaze-b45b0560d748ff02f525665f590e5cd605f289d3.tar.xz
mblaze-b45b0560d748ff02f525665f590e5cd605f289d3.zip
contrib: add msign and mencrypt
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/mencrypt25
-rwxr-xr-xcontrib/msign22
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"'
+