Add GPG recipient support when generating a new tomb key

This commit is contained in:
Alexandre Pujol 2017-01-31 13:45:11 +00:00
parent db7109da4a
commit 902860fd9f

13
tomb
View File

@ -1139,6 +1139,7 @@ gen_key() {
tombpass=""
tombpasstmp=""
{ ! option_is_set -r } && {
if [ "$1" = "" ]; then
while true; do
# 3 tries to write two times a matching password
@ -1194,17 +1195,23 @@ gen_key() {
header="_KDF_pbkdf2sha1_${pbkdf2_salt}_${pbkdf2_iter}_64\n"
}
}
print $header
}
_tmp_create
local tmpres=$TOMBTMP
if option_is_set -r; then
print -n - "${tombpass}\n$TOMBSECRET" \
| gpg --openpgp --force-mdc --cipher-algo ${algo} --batch \
--no-options --no-tty --recipient `option_value -r` \
--status-fd 2 -o - --encrypt --armor 2> $tmpres
else
print -n - "${tombpass}\n$TOMBSECRET" \
| gpg --openpgp --force-mdc --cipher-algo ${algo} --batch \
--no-options --no-tty --passphrase-fd 0 \
--status-fd 2 -o - -c -a 2> $tmpres
--status-fd 2 -o - --symmetric --armor 2> $tmpres
fi
# check result of gpg operation
for i in ${(f)"$(cat $tmpres)"}; do
_verbose "$i"