Add support to change the GPG key used to encrypt a tomb key. (tomb passwd)

This commit is contained in:
Alexandre Pujol 2017-02-02 23:41:09 +00:00
parent 5a35ab9668
commit 47ddeebbc4
2 changed files with 18 additions and 3 deletions

View File

@ -57,7 +57,7 @@ command -v qrencode > /dev/null || QRENCODE=0
typeset -A results
tests=(dig forge lock badpass open close passwd chksum bind setkey
recip-dig recip-forge recip-lock recip-open recip-close)
recip-dig recip-forge recip-lock recip-open recip-close recip-passwd)
{ test $RESIZER = 1 } && { tests+=(resize) }
{ test $KDF = 1 } && { tests+=(kdforge kdfpass kdflock kdfopen) }
{ test $STEGHIDE = 1 } && { tests+=(stgin stgout stgopen stgpipe stgimpl
@ -162,6 +162,16 @@ test-tomb-recip() {
tt close recip
}
notice "Testing tomb with recipient changing gpg key: passwd"
res=0
tt passwd -k $tomb_key -r $gpgid_1 -R $gpgid_2
{ test $? = 0 } || { res=1 }
tt open $tomb -k $tomb_key -r $gpgid_2
{ test $? = 0 } || { res=1 }
tt close recip
{ test $? = 0 } || { res=1 }
{ test $res = 0 } && { results+=(recip-passwd SUCCESS) }
}
test-bind-hooks() {

7
tomb
View File

@ -1173,7 +1173,12 @@ gen_key() {
tombpasstmp=""
{ option_is_set -r } && {
{ option_is_set -R } && {
local gpgkey=`option_value -R`
} || {
local gpgkey=`option_value -r`
}
_verbose "using $gpgkey to encrypt a tomb key"
{ is_valid_recipients "$gpgkey" } || {
_failure "You set an invalid GPG ID."
@ -2669,7 +2674,7 @@ main() {
subcommands_opts[setkey]="k: -ignore-swap -kdf: -tomb-old-pwd: -tomb-pwd: "
subcommands_opts[engrave]="k: "
subcommands_opts[passwd]="k: -ignore-swap -kdf: -tomb-old-pwd: -tomb-pwd: "
subcommands_opts[passwd]="k: -ignore-swap -kdf: -tomb-old-pwd: -tomb-pwd: r: R: "
subcommands_opts[close]=""
subcommands_opts[help]=""
subcommands_opts[slam]=""