Deduplicate openssl cipher name code (and change default value)

This commit is contained in:
Luis López 2019-01-09 12:55:25 +01:00 committed by Tim Byrne
parent baaeb88628
commit bde5ecbc66
No known key found for this signature in database
GPG Key ID: 14DB4FC2465A4B12
1 changed files with 13 additions and 8 deletions

21
yadm
View File

@ -389,6 +389,15 @@ EOF
}
function _get_openssl_ciphername() {
OPENSSL_CIPHERNAME="$(config yadm.openssl-ciphername)"
if [ -z "$OPENSSL_CIPHERNAME" ]; then
OPENSSL_CIPHERNAME="aes-256-cbc"
fi
echo "$OPENSSL_CIPHERNAME"
}
function _decrypt_from() {
local output_archive
@ -410,7 +419,8 @@ function _decrypt_from() {
openssl)
require_openssl
$OPENSSL_PROGRAM enc -d -aes256 -in "$output_archive"
OPENSSL_CIPHERNAME="$(_get_openssl_ciphername)"
$OPENSSL_PROGRAM enc -d -$OPENSSL_CIPHERNAME -salt -in "$output_archive"
;;
*)
@ -452,13 +462,8 @@ function _encrypt_to() {
openssl)
require_openssl
#; Build openssl options for openssl
OPENSSL_CIPHERNAME="$(config yadm.openssl-ciphername)"
if [ -z "$OPENSSL_CIPHERNAME" ]; then
OPENSSL_CIPHERNAME="aes256"
fi
$OPENSSL_PROGRAM enc -"$OPENSSL_CIPHERNAME" -e -out "$output_archive"
OPENSSL_CIPHERNAME="$(_get_openssl_ciphername)"
$OPENSSL_PROGRAM enc -e -$OPENSSL_CIPHERNAME -salt -out "$output_archive"
;;
*)