mblaze

Unix utilities to deal with Maildir - my mirror
git clone https://pi.duncano.de/git/mblaze.git
Log | Files | Refs | README | COPYING

commit b45b0560d748ff02f525665f590e5cd605f289d3
parent 122711840c3d103bbb5d9844c3af01ea555c606c
Author: Leah Neukirchen <leah@vuxu.org>
Date:   Fri, 26 May 2017 23:31:06 +0200

contrib: add msign and mencrypt

Diffstat:
contrib/mencrypt | 25+++++++++++++++++++++++++
contrib/msign | 22++++++++++++++++++++++
2 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/contrib/mencrypt 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 @@ -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"' +