55
55
verify_signatures( int nfiles, char **files )
58
armor_filter_context_t afx;
59
progress_filter_context_t pfx;
58
armor_filter_context_t *afx = NULL;
59
progress_filter_context_t *pfx = new_progress_context ();
60
60
const char *sigfile;
64
memset( &afx, 0, sizeof afx);
65
/* decide whether we should handle a detached or a normal signature,
64
/* Decide whether we should handle a detached or a normal signature,
66
65
* which is needed so that the code later can hash the correct data and
67
66
* not have a normal signature act as detached signature and ignoring the
68
67
* indended signed material from the 2nd file or stdin.
71
70
* 3. gpg file <file2 - detached
72
71
* 4. gpg file file2 - detached
73
72
* The question is how decide between case 2 and 3? The only way
74
* we can do it is by reading one byte from stdin and the unget
73
* we can do it is by reading one byte from stdin and then unget
75
74
* it; the problem here is that we may be reading from the
76
75
* terminal (which could be detected using isatty() but won't work
77
76
* when under contol of a pty using program (e.g. expect)) and
101
99
rc = gpg_error_from_syserror ();
102
100
log_error(_("can't open `%s': %s\n"),
103
101
print_fname_stdin(sigfile), strerror (errno));
106
handle_progress (&pfx, fp, sigfile);
104
handle_progress (pfx, fp, sigfile);
108
if( !opt.no_armor && use_armor_filter( fp ) )
109
iobuf_push_filter( fp, armor_filter, &afx );
106
if ( !opt.no_armor && use_armor_filter( fp ) )
108
afx = new_armor_context ();
109
push_armor_filter (afx, fp);
112
113
for(i=nfiles-1 ; i > 0 ; i-- )
114
115
rc = proc_signature_packets( NULL, fp, sl, sigfile );
115
116
free_strlist(sl);
117
if( (afx.no_openpgp_data && rc == -1) || rc == G10ERR_NO_DATA ) {
118
if( (afx && afx->no_openpgp_data && rc == -1) || rc == G10ERR_NO_DATA ) {
118
119
log_error(_("the signature could not be verified.\n"
119
120
"Please remember that the signature file (.sig or .asc)\n"
120
121
"should be the first file given on the command line.\n") );
126
release_armor_context (afx);
127
release_progress_context (pfx);
129
134
print_file_status( int status, const char *name, int what )
139
144
verify_one_file( const char *name )
142
armor_filter_context_t afx;
143
progress_filter_context_t pfx;
147
armor_filter_context_t *afx = NULL;
148
progress_filter_context_t *pfx = new_progress_context ();
146
151
print_file_status( STATUS_FILE_START, name, 1 );
158
163
log_error(_("can't open `%s': %s\n"),
159
164
print_fname_stdin(name), strerror (errno));
160
165
print_file_status( STATUS_FILE_ERROR, name, 1 );
163
handle_progress (&pfx, fp, name);
168
handle_progress (pfx, fp, name);
165
170
if( !opt.no_armor ) {
166
171
if( use_armor_filter( fp ) ) {
167
memset( &afx, 0, sizeof afx);
168
iobuf_push_filter( fp, armor_filter, &afx );
172
afx = new_armor_context ();
173
push_armor_filter (afx, fp);
172
177
rc = proc_signature_packets( NULL, fp, NULL, name );
174
179
write_status( STATUS_FILE_DONE );
182
release_armor_context (afx);
183
release_progress_context (pfx);
225
/* Perform a verify operation. To verify detached signatures, DATA_FD
226
shall be the descriptor of the signed data; for regular signatures
227
it needs to be -1. If OUT_FP is not NULL and DATA_FD is not -1 the
228
the signed material gets written that stream.
230
FIXME: OUTFP is not yet implemented.
233
gpg_verify (ctrl_t ctrl, int sig_fd, int data_fd, FILE *out_fp)
237
armor_filter_context_t *afx = NULL;
238
progress_filter_context_t *pfx = new_progress_context ();
240
fp = iobuf_fdopen (sig_fd, "rb");
241
if (fp && is_secured_file (sig_fd))
248
rc = gpg_error_from_syserror ();
249
log_error (_("can't open fd %d: %s\n"), sig_fd, strerror (errno));
253
handle_progress (pfx, fp, NULL);
255
if ( !opt.no_armor && use_armor_filter (fp) )
257
afx = new_armor_context ();
258
push_armor_filter (afx, fp);
261
rc = proc_signature_packets_by_fd ( NULL, fp, data_fd );
263
if ( afx && afx->no_openpgp_data
264
&& (rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF) )
265
rc = gpg_error (GPG_ERR_NO_DATA);
270
release_progress_context (pfx);
271
release_armor_context (afx);