1
1
/* decrypt.c - verify signed data
2
* Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
2
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
3
* 2007 Free Software Foundation, Inc.
4
5
* This file is part of GnuPG.
6
7
* GnuPG is free software; you can redistribute it and/or modify
7
8
* 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
* the Free Software Foundation; either version 3 of the License, or
9
10
* (at your option) any later version.
11
12
* GnuPG is distributed in the hope that it will be useful,
14
15
* GNU General Public License for more details.
16
17
* 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
18
* along with this program; if not, see <http://www.gnu.org/licenses/>.
21
21
#include <config.h>
50
50
decrypt_message( const char *filename )
53
armor_filter_context_t afx;
54
progress_filter_context_t pfx;
53
armor_filter_context_t *afx = NULL;
54
progress_filter_context_t *pfx;
58
/* open the message file */
58
pfx = new_progress_context ();
60
/* Open the message file. */
59
61
fp = iobuf_open(filename);
62
if (fp && is_secured_file (iobuf_get_fd (fp)))
61
rc = gpg_error_from_errno (errno);
62
log_error(_("can't open `%s'\n"), print_fname_stdin(filename));
69
rc = gpg_error_from_syserror ();
70
log_error (_("can't open `%s': %s\n"), print_fname_stdin(filename),
72
release_progress_context (pfx);
66
handle_progress (&pfx, fp, filename);
76
handle_progress (pfx, fp, filename);
68
78
if( !opt.no_armor ) {
69
79
if( use_armor_filter( fp ) ) {
70
memset( &afx, 0, sizeof afx);
71
iobuf_push_filter( fp, armor_filter, &afx );
80
afx = new_armor_context ();
81
push_armor_filter ( afx, fp );
81
91
opt.outfile = NULL;
93
release_armor_context (afx);
94
release_progress_context (pfx);
87
decrypt_messages(int nfiles, char **files)
99
decrypt_messages(int nfiles, char *files[])
90
armor_filter_context_t afx;
91
progress_filter_context_t pfx;
102
armor_filter_context_t *afx = NULL;
103
progress_filter_context_t *pfx;
92
104
char *p, *output = NULL;
105
int rc=0,use_stdin=0;
97
110
log_error(_("--output doesn't work for this command\n"));
114
pfx = new_progress_context ();
104
print_file_status(STATUS_FILE_START, *files, 3);
105
output = make_outfile_name(*files);
126
if(fgets(line, DIM(line), stdin))
129
if (!*line || line[strlen(line)-1] != '\n')
130
log_error("input line %u too long or missing LF\n", lno);
133
line[strlen(line)-1] = '\0';
151
print_file_status(STATUS_FILE_START, filename, 3);
152
output = make_outfile_name(filename);
108
fp = iobuf_open(*files);
155
fp = iobuf_open(filename);
157
iobuf_ioctl (fp,3,1,NULL); /* disable fd caching */
158
if (fp && is_secured_file (iobuf_get_fd (fp)))
111
log_error(_("can't open `%s'\n"), print_fname_stdin(*files));
166
log_error(_("can't open `%s'\n"), print_fname_stdin(filename));
115
handle_progress (&pfx, fp, *files);
170
handle_progress (pfx, fp, filename);
117
172
if (!opt.no_armor)
119
174
if (use_armor_filter(fp))
121
memset(&afx, 0, sizeof afx);
122
iobuf_push_filter(fp, armor_filter, &afx);
176
afx = new_armor_context ();
177
push_armor_filter ( afx, fp );
125
180
rc = proc_packets(NULL, fp);
128
log_error("%s: decryption failed: %s\n", print_fname_stdin(*files),
183
log_error("%s: decryption failed: %s\n", print_fname_stdin(filename),
130
185
p = get_last_passphrase();
131
186
set_next_passphrase(p);