while [ -z "$REPLY" -o -z "$dup_gpg_encryptkey" ]; do
inputBox "$dup_title - GnuPG" "Enter the GnuPG key ID to be used to encrypt the backups:" "$dup_gpg_encryptkey"
inputBox "$dup_title - GnuPG" "Enter ID of the public GnuPG key to be used to encrypt the backups:" "$dup_gpg_encryptkey"
[ $? = 0 ] || return 1
dup_gpg_encryptkey="$REPLY"
done
}
do_dup_gpg_sign() {
# sign ?
booleanBox "$dup_title - GnuPG" "Sign the backups?" "$dup_gpg_sign"
if [ $? = 0 ]; then
dup_gpg_sign=yes
else
dup_gpg_sign=no
fi
}
do_dup_gpg_signkey() {
# one key pair ?
booleanBox "$dup_title - GnuPG" "Use the same GnuPG key pair for encryption and signing?" "$dup_gpg_onekeypair"
if [ $? = 0 ]; then
dup_gpg_onekeypair=yes
else
dup_gpg_onekeypair=no
fi
# passphrase ?
if [ "$dup_gpg_onekeypair" == "no" }; then
# signkey ?
REPLY=
while [ -z "$REPLY" -o -z "$dup_gpg_signkey" ]; do
inputBox "$dup_title - GnuPG" "Enter the ID of the private GnuPG key to be used to sign the backups:" "$dup_gpg_signkey"
[ $? = 0 ] || return 1
dup_gpg_signkey="$REPLY"
done
fi
}
do_dup_gpg_passphrase() {
local question="Enter the passphrase needed to $@:"
REPLY=
while [ -z "$REPLY" -o -z "$dup_gpg_password" ]; do
passwordBox "$dup_title - GnuPG" "Enter the passphrase needed to unlock the key 0x$dup_gpg_encryptkey"
passwordBox "$dup_title - GnuPG" "$question"
[ $? = 0 ] || return 1
dup_gpg_password="$REPLY"
done
}
# sign ?
booleanBox "$dup_title - GnuPG" "Sign the backups?" "$dup_gpg_sign"
do_dup_gpg() {
# symmetric or public key encryption ?
booleanBox "$dup_title - GnuPG" "Use public key encryption? Else, symmetric encryption will be used, and data signing will be impossible." "$dup_gpg_asymmetric_encryption"
if [ $? = 0 ]; then
dup_gpg_sign=yes
dup_gpg_asymmetric_encryption=yes
else
dup_gpg_sign=no
dup_gpg_asymmetric_encryption=no
fi
# when using public/private key pair encryption, ask for the keys to use
if [ "$dup_gpg_asymmetric_encryption" == yes ]; then
do_dup_gpg_encryptkey ; [ $? = 0 ] || return 1
do_dup_gpg_sign ; [ $? = 0 ] || return 1
if [ "$dup_gpg_sign" == yes ]; then
do_dup_gpg_signkey ; [ $? = 0 ] || return 1
fi
fi
# a passphrase is only needed when signing, or when symmetric encryption is used
if [ "$dup_gpg_asymmetric_encryption" == "no" ]; then
do_dup_gpg_passphrase "encrypt the backups"
[ $? = 0 ] || return 1
elif [ "$dup_gpg_sign" == "yes" ]; then
if [ -z "$dup_gpg_signkey" ]; then
do_dup_gpg_passphrase "unlock the GnuPG 0x$dup_gpg_signkey key used to sign the backups"
[ $? = 0 ] || return 1
else
do_dup_gpg_passphrase "unlock the GnuPG 0x$dup_gpg_encryptkey key used to sign the backups"
[ $? = 0 ] || return 1
fi
fi
set +o noglob
_gpg_done="(DONE)"
setDefault adv
# TODO: replace the above line by the following when do_dup_conn is written