mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-21 14:47:03 +01:00
tools/gpgtar: Implement symmetric encryption.
* tests/openpgp/gpgtar.test: Add test case. * tools/gpgtar-create.c (gpgtar_create): Pass '--symmetric' flag to gpg. * tools/gpgtar.c (parse_arguments): We do handle the argument now. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
45c814f348
commit
582e684a48
@ -24,6 +24,7 @@ TESTFILES="$plain_files $data_files"
|
||||
|
||||
TESTDIR=gpgtar.d
|
||||
FILELIST="${TESTDIR}/filelist"
|
||||
PPFILE="${TESTDIR}/passphrase"
|
||||
GPG=../../g10/gpg2
|
||||
GPGARGS="$opt_always --no-permission-warning"
|
||||
|
||||
@ -46,6 +47,7 @@ do_test()
|
||||
|
||||
rm -rf -- "${TESTDIR}"
|
||||
mkdir "${TESTDIR}"
|
||||
echo frob >"$PPFILE"
|
||||
|
||||
$TOOL --gpg "$GPG" --gpg-args "$GPGARGS" $CREATE_FLAGS \
|
||||
--output "${TESTDIR}/test.tar.pgp" $TESTFILES
|
||||
@ -69,6 +71,7 @@ do_test()
|
||||
}
|
||||
|
||||
for TOOL in "$GPGTAR" "$GPGZIP"
|
||||
#for TOOL in "$GPGZIP"
|
||||
do
|
||||
do_test "$TOOL" \
|
||||
"--encrypt --recipient $usrname2" \
|
||||
@ -84,6 +87,11 @@ do
|
||||
"--sign --local-user $usrname3" \
|
||||
"--list-archive" \
|
||||
"--decrypt"
|
||||
|
||||
do_test "$TOOL" \
|
||||
"--gpg-args --passphrase-file=$PPFILE --symmetric" \
|
||||
"--gpg-args --passphrase-file=$PPFILE --list-archive" \
|
||||
"--gpg-args --passphrase-file=$PPFILE --decrypt"
|
||||
done
|
||||
|
||||
# Success!
|
||||
|
@ -896,9 +896,16 @@ gpgtar_create (char **inpattern, int encrypt, int sign)
|
||||
if (err)
|
||||
goto leave;
|
||||
|
||||
/* '--encrypt' may be combined with '--symmetric', but 'encrypt'
|
||||
is set either way. Clear it if no recipients are specified.
|
||||
XXX: Fix command handling. */
|
||||
if (opt.symmetric && opt.recipients == NULL)
|
||||
encrypt = 0;
|
||||
|
||||
argv = xtrycalloc (strlist_length (opt.gpg_arguments)
|
||||
+ 2 * strlist_length (opt.recipients)
|
||||
+ 1 + !!encrypt + !!sign + 2 * !!opt.user,
|
||||
+ 1 + !!encrypt + !!sign + 2 * !!opt.user
|
||||
+ !!opt.symmetric,
|
||||
sizeof *argv);
|
||||
if (argv == NULL)
|
||||
{
|
||||
@ -915,6 +922,8 @@ gpgtar_create (char **inpattern, int encrypt, int sign)
|
||||
argv[i++] = "--local-user";
|
||||
argv[i++] = opt.user;
|
||||
}
|
||||
if (opt.symmetric)
|
||||
argv[i++] = "--symmetric";
|
||||
for (arg = opt.recipients; arg; arg = arg->next)
|
||||
{
|
||||
argv[i++] = "--recipient";
|
||||
@ -925,7 +934,8 @@ gpgtar_create (char **inpattern, int encrypt, int sign)
|
||||
argv[i++] = NULL;
|
||||
assert (i == strlist_length (opt.gpg_arguments)
|
||||
+ 2 * strlist_length (opt.recipients)
|
||||
+ 1 + !!encrypt + !!sign + 2 * !!opt.user);
|
||||
+ 1 + !!encrypt + !!sign + 2 * !!opt.user
|
||||
+ !!opt.symmetric);
|
||||
|
||||
err = sh_exec_tool_stream (opt.gpg_program, argv,
|
||||
outstream, cipher_stream);
|
||||
|
@ -322,7 +322,6 @@ parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
|
||||
break;
|
||||
|
||||
case oSymmetric:
|
||||
log_info ("note: ignoring option --symmetric\n");
|
||||
set_cmd (&cmd, aEncrypt);
|
||||
opt.symmetric = 1;
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user