1
/* decrypt.c - verify signed data
2
* Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
4
* This file is part of GnuPG.
6
* GnuPG is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* GnuPG is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
42
* Assume that the input is an encrypted message and decrypt
43
* (and if signed, verify the signature on) it.
44
* This command differs from the default operation, as it never
45
* writes to the filename which is included in the file and it
46
* rejects files which don't begin with an encrypted message.
50
decrypt_message( const char *filename )
53
armor_filter_context_t afx;
54
progress_filter_context_t pfx;
58
/* open the message file */
59
fp = iobuf_open(filename);
61
rc = gpg_error_from_errno (errno);
62
log_error(_("can't open `%s'\n"), print_fname_stdin(filename));
66
handle_progress (&pfx, fp, filename);
69
if( use_armor_filter( fp ) ) {
70
memset( &afx, 0, sizeof afx);
71
iobuf_push_filter( fp, armor_filter, &afx );
79
rc = proc_encryption_packets( NULL, fp );
87
decrypt_messages(int nfiles, char **files)
90
armor_filter_context_t afx;
91
progress_filter_context_t pfx;
92
char *p, *output = NULL;
97
log_error(_("--output doesn't work for this command\n"));
104
print_file_status(STATUS_FILE_START, *files, 3);
105
output = make_outfile_name(*files);
108
fp = iobuf_open(*files);
111
log_error(_("can't open `%s'\n"), print_fname_stdin(*files));
115
handle_progress (&pfx, fp, *files);
119
if (use_armor_filter(fp))
121
memset(&afx, 0, sizeof afx);
122
iobuf_push_filter(fp, armor_filter, &afx);
125
rc = proc_packets(NULL, fp);
128
log_error("%s: decryption failed: %s\n", print_fname_stdin(*files),
130
p = get_last_passphrase();
131
set_next_passphrase(p);
135
/* Note that we emit file_done even after an error. */
136
write_status( STATUS_FILE_DONE );
140
set_next_passphrase(NULL);