ソースを参照

Add three proof of concept scripts

Signed-off-by: Aoi Koizumi <novaburst@kalli.st>
master
コミット
47455c7af7
  1. 24
      experimental/age_encrypt
  2. 33
      experimental/mautocrypt
  3. 24
      experimental/saltpack_encrypt

24
experimental/age_encrypt

@ -0,0 +1,24 @@
#!/bin/sh
[ -f "$1" ] || exit 1
IFS='
'
FLAGS=$(maddr -a -h from:to:cc:bcc "$1" | sort -u | sed 's/^/--recipients-file/')
FROM=$(maddr -a -h from: "$1" | sed 1q)
TO=$(maddr -a -h to: "$1" | sed 1q)
TMPD=$(mktemp -d magecrypt.XXXXXX)
trap "rm -rf '$TMPD'" INT TERM EXIT
awk '/^$/,0' | mmime | age --encrypt "$FLAGS" "$TO.age" -o "$TMPD/msg.age" || exit $?
printf 'Version: 1\n' > "$TMPD/version"
{
sed 's/^$/q' "$1"
printf '#application/age-encrypted %s/version' "$TMPD"
printf '#application/octet-stream %s/msg.age\n' "$TMPD"
} |
mmime -t 'multipart/encrypted; protocol="application/age-encrypted"'

33
experimental/mautocrypt

@ -0,0 +1,33 @@
#!/bin/sh
# mencrypt PLAINMSG - generate a PGP/MIME signed and encrypted message
[ -f "$1" ] || exit 1
IFS='
'
FLAGS=$(maddr -a -h from:to:cc:bcc: "$1" |sort -u |sed 's/^/--recipient=/')
FROM=$(maddr -a -h from "$1" | sed 1q)
[ "$FROM" ] && key="--default-key=$FROM"
if command -v gpg2 >/dev/null; then
GPG=gpg2
else
GPG=gpg
fi
TMPD=$(mktemp -d -t mencrypt.XXXXXX)
trap "rm -rf '$TMPD'" INT TERM EXIT
export GPG_TTY=$(tty)
awk '/^$/,0' "$1" | mmime | $GPG "$key" --armor --encrypt --sign $FLAGS -o "$TMPD/msg.asc" || exit $?
unset GPG_TTY
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"'

24
experimental/saltpack_encrypt

@ -0,0 +1,24 @@
#!/bin/sh
[ -f "$1" ] || exit 1
IFS='
'
FLAGS=$(maddr -a -h from:to:cc:bcc "$1" | sort -u | sed 's/^/--recipients/')
FROM=$(maddr -a -h from: "$1" | sed 1q)
TO=$(maddr -a -h to: "$1" | sed 1q)
TMPD=$(mktemp -d msaltcrypt.XXXXXX)
trap "rm -rf '$TMPD'" INT TERM EXIT
awk '/^$/,0' | mmime | salty --encrypt "$FLAGS" "$TO.slt" -o "$TMPD/msg.slt" || exit $?
printf 'Version: 1\n' > "$TMPD/version"
{
sed 's/^$/q' "$1"
printf '#application/salty-encrypted %s/version' "$TMPD"
printf '#application/octet-stream %s/msg.slt\n' "$TMPD"
} |
mmime -t 'multipart/encrypted; protocol="application/saltpack-encrypted"'
読み込み中…
キャンセル
保存