1998-03-09 22:44:06 +01:00
|
|
|
/* verify.c - verify signed data
|
|
|
|
* Copyright (C) 1998 Free Software Foundation, Inc.
|
|
|
|
*
|
1998-12-23 13:41:40 +01:00
|
|
|
* This file is part of GnuPG.
|
1998-03-09 22:44:06 +01:00
|
|
|
*
|
1998-12-23 13:41:40 +01:00
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
1998-03-09 22:44:06 +01:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
1998-12-23 13:41:40 +01:00
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
1998-03-09 22:44:06 +01:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "options.h"
|
|
|
|
#include "packet.h"
|
|
|
|
#include "errors.h"
|
|
|
|
#include "iobuf.h"
|
|
|
|
#include "keydb.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "filter.h"
|
|
|
|
#include "ttyio.h"
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************
|
|
|
|
* Assume that the input is a signature and verify it without
|
1998-04-14 19:51:16 +02:00
|
|
|
* generating any output. With no arguments, the signature packet
|
1998-03-09 22:44:06 +01:00
|
|
|
* is read from stdin (it may be a detached signature when not
|
1998-04-14 19:51:16 +02:00
|
|
|
* used in batch mode). If only a sigfile is given, it may be a complete
|
1998-03-09 22:44:06 +01:00
|
|
|
* signature or a detached signature in which case the signed stuff
|
|
|
|
* is expected from stdin. With more than 1 argument, the first should
|
|
|
|
* be a detached signature and the remaining files are the signed stuff.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
verify_signatures( int nfiles, char **files )
|
|
|
|
{
|
|
|
|
IOBUF fp;
|
|
|
|
armor_filter_context_t afx;
|
|
|
|
const char *sigfile;
|
|
|
|
int i, rc;
|
|
|
|
STRLIST sl;
|
|
|
|
|
|
|
|
sigfile = nfiles? *files : NULL;
|
|
|
|
|
|
|
|
/* open the signature file */
|
|
|
|
fp = iobuf_open(sigfile);
|
|
|
|
if( !fp ) {
|
1998-12-29 14:47:31 +01:00
|
|
|
log_error(_("can't open `%s'\n"), print_fname_stdin(sigfile));
|
1998-03-09 22:44:06 +01:00
|
|
|
return G10ERR_OPEN_FILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !opt.no_armor ) {
|
|
|
|
if( use_armor_filter( fp ) ) {
|
|
|
|
memset( &afx, 0, sizeof afx);
|
|
|
|
iobuf_push_filter( fp, armor_filter, &afx );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sl = NULL;
|
|
|
|
for(i=1 ; i < nfiles; i++ )
|
|
|
|
add_to_strlist( &sl, files[i] );
|
1999-04-26 17:53:01 +02:00
|
|
|
rc = proc_signature_packets( NULL, fp, sl, sigfile );
|
1998-03-09 22:44:06 +01:00
|
|
|
free_strlist(sl);
|
|
|
|
iobuf_close(fp);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|