aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-08-06 20:43:08 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-08-06 20:43:08 +0200
commite2679e44234f24d9a8c4cb4d64d531e9fc03d455 (patch)
tree7815efb46ca02bf93a407e781425de3c97a39b98
parent7377f0dfc3a262e3110a046eafa1d61cbbd32bc7 (diff)
downloadmblaze-e2679e44234f24d9a8c4cb4d64d531e9fc03d455.tar.gz
add contrib/mverify to verify a OpenPGP or SMIME message
-rwxr-xr-xcontrib/mverify33
1 files changed, 33 insertions, 0 deletions
diff --git a/contrib/mverify b/contrib/mverify
new file mode 100755
index 0000000..563d0b1
--- /dev/null
+++ b/contrib/mverify
@@ -0,0 +1,33 @@
+#!/bin/sh
+# mverify MSG - verify a OpenPGP or SMIME message
+
+# Needs bash, gpg and openssl.
+
+[ "$#" -eq 0 ] && set -- .
+
+mshow -t "$1" | awk -v "msg=$1" '
+{ match($0, "^ *"); indent = RLENGTH }
+$2 == "text/plain" { plain++ }
+$2 == "multipart/signed" { signed = +$1; si = indent; next }
+signed && !content && indent == si+2 { content = +$1; next }
+signed && content && !signature && indent == si+2 { signature = +$1; type = $2 }
+function q(a) { gsub("\\47", "\47\\\47\47", a); return "\47"a"\47" }
+END {
+ if (type == "" && plain) { // guess plain text armored signature
+ exit(system("mshow -R " q(msg) " | gpg --verify"));
+ } else if (type == "") {
+ print("No signature found.")
+ exit(100)
+ } else if (type == "application/pgp-signature") {
+ exit(system("bash -c " q("mshow -r -O " q(msg) " " q(content) \
+ " | sed 's/$/\\r/' | gpg --verify <(mshow -O " q(msg) \
+ " " q(signature) " ) -")))
+ } else if (type == "application/pkcs7-signature") {
+ exit(system("mshow -r -O " q(msg) " " q(signed) \
+ " | openssl smime -verify"))
+ } else {
+ print("Cant verify signatures of type " type ".")
+ exit(2)
+ }
+}
+'