mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-10 13:04:23 +01:00
New command --decrypt-files.
Some fixes.
This commit is contained in:
parent
b3a5994235
commit
e17cd91abe
@ -221,7 +221,8 @@ more arguments in future versions.
|
|||||||
Start processing a file <filename>. <what> indicates the performed
|
Start processing a file <filename>. <what> indicates the performed
|
||||||
operation:
|
operation:
|
||||||
1 - verify
|
1 - verify
|
||||||
2 - encrypt
|
2 - encrypt
|
||||||
|
3 - decrypt
|
||||||
|
|
||||||
FILE_DONE
|
FILE_DONE
|
||||||
Marks the end of a file processing which has been started
|
Marks the end of a file processing which has been started
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
2002-01-15 Timo Schulz <ts@winpt.org>
|
||||||
|
|
||||||
|
* encode.c (encode_crypt_files): Fail if --output is used.
|
||||||
|
|
||||||
|
* g10.c: New command --decrypt-files.
|
||||||
|
|
||||||
|
* decrypt.c (decrypt_messages): New.
|
||||||
|
|
||||||
2002-01-09 David Shaw <dshaw@jabberwocky.com>
|
2002-01-09 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* g10.c, misc.c, gpgv.c: move idea_cipher_warn to misc.c so gpgv.c
|
* g10.c, misc.c, gpgv.c: move idea_cipher_warn to misc.c so gpgv.c
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "status.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
||||||
|
|
||||||
@ -78,5 +79,59 @@ decrypt_message( const char *filename )
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
decrypt_messages(int nfiles, char **files)
|
||||||
|
{
|
||||||
|
IOBUF fp;
|
||||||
|
armor_filter_context_t afx;
|
||||||
|
char *p, *output = NULL;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
if (opt.outfile)
|
||||||
|
{
|
||||||
|
log_error(_("--output doesn't work for this command\n"));
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
while (nfiles--)
|
||||||
|
{
|
||||||
|
print_file_status(STATUS_FILE_START, *files, 3);
|
||||||
|
output = make_outfile_name(*files);
|
||||||
|
if (!output)
|
||||||
|
continue;
|
||||||
|
fp = iobuf_open(*files);
|
||||||
|
if (!fp)
|
||||||
|
{
|
||||||
|
log_error(_("can't open `%s'\n"), print_fname_stdin(*files));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!opt.no_armor)
|
||||||
|
{
|
||||||
|
if (use_armor_filter(fp))
|
||||||
|
{
|
||||||
|
memset(&afx, 0, sizeof afx);
|
||||||
|
iobuf_push_filter(fp, armor_filter, &afx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rc = proc_packets(NULL, fp);
|
||||||
|
iobuf_close(fp);
|
||||||
|
if (rc)
|
||||||
|
log_error("%s: decryption failed: %s\n", print_fname_stdin(*files),
|
||||||
|
g10_errstr(rc));
|
||||||
|
p = get_last_passphrase();
|
||||||
|
set_next_passphrase(p);
|
||||||
|
files++;
|
||||||
|
m_free(output);
|
||||||
|
write_status( STATUS_FILE_DONE );
|
||||||
|
}
|
||||||
|
set_next_passphrase(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
77
g10/encode.c
77
g10/encode.c
@ -568,47 +568,46 @@ write_pubkey_enc_from_list( PK_LIST pk_list, DEK *dek, IOBUF out )
|
|||||||
void
|
void
|
||||||
encode_crypt_files(int nfiles, char **files, STRLIST remusr)
|
encode_crypt_files(int nfiles, char **files, STRLIST remusr)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if (opt.outfile)
|
if (opt.outfile)
|
||||||
{
|
{
|
||||||
if (opt.verbose)
|
log_error(_("--output doesn't work for this command\n"));
|
||||||
log_info(_("ignore --output for multiple files"));
|
return;
|
||||||
opt.outfile = NULL;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!nfiles)
|
if (!nfiles)
|
||||||
{
|
{
|
||||||
char line[2048];
|
char line[2048];
|
||||||
unsigned int lno = 0;
|
unsigned int lno = 0;
|
||||||
while ( fgets(line, DIM(line), stdin) )
|
while ( fgets(line, DIM(line), stdin) )
|
||||||
{
|
{
|
||||||
lno++;
|
lno++;
|
||||||
if (!*line || line[strlen(line)-1] != '\n')
|
if (!*line || line[strlen(line)-1] != '\n')
|
||||||
{
|
{
|
||||||
log_error("input line %u too long or missing LF\n", lno);
|
log_error("input line %u too long or missing LF\n", lno);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
line[strlen(line)-1] = '\0';
|
line[strlen(line)-1] = '\0';
|
||||||
print_file_status(STATUS_FILE_START, line, 2);
|
print_file_status(STATUS_FILE_START, line, 2);
|
||||||
if ( (rc = encode_crypt(line, remusr)) )
|
if ( (rc = encode_crypt(line, remusr)) )
|
||||||
log_error("%s: encryption failed: %s\n",
|
log_error("%s: encryption failed: %s\n",
|
||||||
print_fname_stdin(line), g10_errstr(rc) );
|
print_fname_stdin(line), g10_errstr(rc) );
|
||||||
write_status( STATUS_FILE_DONE );
|
write_status( STATUS_FILE_DONE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (nfiles--)
|
while (nfiles--)
|
||||||
{
|
{
|
||||||
print_file_status(STATUS_FILE_START, *files, 2);
|
print_file_status(STATUS_FILE_START, *files, 2);
|
||||||
if ( (rc = encode_crypt(*files, remusr)) )
|
if ( (rc = encode_crypt(*files, remusr)) )
|
||||||
log_error("%s: encryption failed: %s\n",
|
log_error("%s: encryption failed: %s\n",
|
||||||
print_fname_stdin(*files), g10_errstr(rc) );
|
print_fname_stdin(*files), g10_errstr(rc) );
|
||||||
write_status( STATUS_FILE_DONE );
|
write_status( STATUS_FILE_DONE );
|
||||||
files++;
|
files++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ enum cmd_and_opt_values { aNull = 0,
|
|||||||
oShowNotation,
|
oShowNotation,
|
||||||
oNoShowNotation,
|
oNoShowNotation,
|
||||||
oBatch = 500,
|
oBatch = 500,
|
||||||
|
aDecryptFiles,
|
||||||
aClearsign,
|
aClearsign,
|
||||||
aStore,
|
aStore,
|
||||||
aKeygen,
|
aKeygen,
|
||||||
@ -273,6 +274,7 @@ static ARGPARSE_OPTS opts[] = {
|
|||||||
{ aSym, "symmetric", 256, N_("encryption only with symmetric cipher")},
|
{ aSym, "symmetric", 256, N_("encryption only with symmetric cipher")},
|
||||||
{ aStore, "store", 256, N_("store only")},
|
{ aStore, "store", 256, N_("store only")},
|
||||||
{ aDecrypt, "decrypt", 256, N_("decrypt data (default)")},
|
{ aDecrypt, "decrypt", 256, N_("decrypt data (default)")},
|
||||||
|
{ aDecryptFiles, "decrypt-files", 256, N_("|[files]|decrypt files")},
|
||||||
{ aVerify, "verify" , 256, N_("verify a signature")},
|
{ aVerify, "verify" , 256, N_("verify a signature")},
|
||||||
{ aVerifyFiles, "verify-files" , 256, "@" },
|
{ aVerifyFiles, "verify-files" , 256, "@" },
|
||||||
{ aListKeys, "list-keys", 256, N_("list keys")},
|
{ aListKeys, "list-keys", 256, N_("list keys")},
|
||||||
@ -900,6 +902,7 @@ main( int argc, char **argv )
|
|||||||
case aSym: set_cmd( &cmd, aSym); break;
|
case aSym: set_cmd( &cmd, aSym); break;
|
||||||
|
|
||||||
case aDecrypt: set_cmd( &cmd, aDecrypt); break;
|
case aDecrypt: set_cmd( &cmd, aDecrypt); break;
|
||||||
|
case aDecryptFiles: set_cmd( &cmd, aDecryptFiles); break;
|
||||||
|
|
||||||
case aEncr: set_cmd( &cmd, aEncr); break;
|
case aEncr: set_cmd( &cmd, aEncr); break;
|
||||||
case aEncrFiles: set_cmd( &cmd, aEncrFiles ); break;
|
case aEncrFiles: set_cmd( &cmd, aEncrFiles ); break;
|
||||||
@ -1611,7 +1614,10 @@ main( int argc, char **argv )
|
|||||||
log_error("decrypt_message failed: %s\n", g10_errstr(rc) );
|
log_error("decrypt_message failed: %s\n", g10_errstr(rc) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case aDecryptFiles:
|
||||||
|
decrypt_messages(argc, argv);
|
||||||
|
break;
|
||||||
|
|
||||||
case aSignKey: /* sign the key given as argument */
|
case aSignKey: /* sign the key given as argument */
|
||||||
if( argc != 1 )
|
if( argc != 1 )
|
||||||
wrong_args(_("--sign-key user-id"));
|
wrong_args(_("--sign-key user-id"));
|
||||||
|
@ -169,6 +169,7 @@ int verify_files( int nfiles, char **files );
|
|||||||
|
|
||||||
/*-- decrypt.c --*/
|
/*-- decrypt.c --*/
|
||||||
int decrypt_message( const char *filename );
|
int decrypt_message( const char *filename );
|
||||||
|
void decrypt_messages(int nfiles, char **files);
|
||||||
|
|
||||||
/*-- plaintext.c --*/
|
/*-- plaintext.c --*/
|
||||||
int hash_datafiles( MD_HANDLE md, MD_HANDLE md2,
|
int hash_datafiles( MD_HANDLE md, MD_HANDLE md2,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user