2006-04-19 11:26:11 +00:00
|
|
|
/* verify.c - Verify signed data
|
2007-05-03 04:44:12 +00:00
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006,
|
2010-03-08 18:19:21 +00:00
|
|
|
* 2007, 2010 Free Software Foundation, Inc.
|
2023-04-05 21:32:23 +02:00
|
|
|
* Copyright (C) 2003, 2006-2008, 2010-2011, 2015-2017,
|
|
|
|
* 2020, 2023 g10 Code GmbH
|
2003-06-05 07:14:21 +00:00
|
|
|
*
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
*
|
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-04 19:49:40 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-06-05 07:14:21 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
|
|
|
* 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
|
2016-11-05 12:02:19 +01:00
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2023-04-05 21:32:23 +02:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2003-06-05 07:14:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2006-04-19 11:26:11 +00:00
|
|
|
#include "gpg.h"
|
2003-06-05 07:14:21 +00:00
|
|
|
#include "options.h"
|
|
|
|
#include "packet.h"
|
2017-03-07 20:21:23 +09:00
|
|
|
#include "../common/status.h"
|
|
|
|
#include "../common/iobuf.h"
|
2003-06-05 07:14:21 +00:00
|
|
|
#include "keydb.h"
|
2017-03-07 20:21:23 +09:00
|
|
|
#include "../common/util.h"
|
2003-06-05 07:14:21 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include "filter.h"
|
2017-03-07 20:21:23 +09:00
|
|
|
#include "../common/ttyio.h"
|
|
|
|
#include "../common/i18n.h"
|
2003-06-05 07:14:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
/****************
|
|
|
|
* Assume that the input is a signature and verify it without
|
|
|
|
* generating any output. With no arguments, the signature packet
|
|
|
|
* is read from stdin (it may be a detached signature when not
|
|
|
|
* used in batch mode). If only a sigfile is given, it may be a complete
|
|
|
|
* 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
|
2010-10-01 20:33:53 +00:00
|
|
|
verify_signatures (ctrl_t ctrl, int nfiles, char **files )
|
2003-06-05 07:14:21 +00:00
|
|
|
{
|
2006-04-19 11:26:11 +00:00
|
|
|
IOBUF fp;
|
2006-12-21 19:40:00 +00:00
|
|
|
armor_filter_context_t *afx = NULL;
|
|
|
|
progress_filter_context_t *pfx = new_progress_context ();
|
2003-06-05 07:14:21 +00:00
|
|
|
const char *sigfile;
|
|
|
|
int i, rc;
|
2006-10-02 11:54:35 +00:00
|
|
|
strlist_t sl;
|
2003-06-05 07:14:21 +00:00
|
|
|
|
2006-12-21 19:40:00 +00:00
|
|
|
/* Decide whether we should handle a detached or a normal signature,
|
2003-06-05 07:14:21 +00:00
|
|
|
* which is needed so that the code later can hash the correct data and
|
|
|
|
* not have a normal signature act as detached signature and ignoring the
|
2017-04-28 10:06:33 +09:00
|
|
|
* intended signed material from the 2nd file or stdin.
|
2003-06-05 07:14:21 +00:00
|
|
|
* 1. gpg <file - normal
|
|
|
|
* 2. gpg file - normal (or detached)
|
|
|
|
* 3. gpg file <file2 - detached
|
|
|
|
* 4. gpg file file2 - detached
|
|
|
|
* The question is how decide between case 2 and 3? The only way
|
2006-12-21 19:40:00 +00:00
|
|
|
* we can do it is by reading one byte from stdin and then unget
|
2003-06-05 07:14:21 +00:00
|
|
|
* it; the problem here is that we may be reading from the
|
|
|
|
* terminal (which could be detected using isatty() but won't work
|
2018-10-24 15:56:18 -04:00
|
|
|
* when under control of a pty using program (e.g. expect)) and
|
2003-06-05 07:14:21 +00:00
|
|
|
* might get us in trouble when stdin is used for another purpose
|
|
|
|
* (--passphrase-fd 0). So we have to break with the behaviour
|
|
|
|
* prior to gpg 1.0.4 by assuming that case 3 is a normal
|
|
|
|
* signature (where file2 is ignored and require for a detached
|
|
|
|
* signature to indicate signed material comes from stdin by using
|
|
|
|
* case 4 with a file2 of "-".
|
|
|
|
*
|
|
|
|
* Actually we don't have to change anything here but can handle
|
2011-02-04 12:57:53 +01:00
|
|
|
* that all quite easily in mainproc.c
|
2003-06-05 07:14:21 +00:00
|
|
|
*/
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2003-06-05 07:14:21 +00:00
|
|
|
sigfile = nfiles? *files : NULL;
|
|
|
|
|
|
|
|
/* open the signature file */
|
|
|
|
fp = iobuf_open(sigfile);
|
2006-04-19 11:26:11 +00:00
|
|
|
if (fp && is_secured_file (iobuf_get_fd (fp)))
|
|
|
|
{
|
|
|
|
iobuf_close (fp);
|
|
|
|
fp = NULL;
|
2010-04-01 13:24:55 +00:00
|
|
|
gpg_err_set_errno (EPERM);
|
2006-04-19 11:26:11 +00:00
|
|
|
}
|
2003-06-05 07:14:21 +00:00
|
|
|
if( !fp ) {
|
2006-09-14 16:50:33 +00:00
|
|
|
rc = gpg_error_from_syserror ();
|
2012-06-05 19:29:22 +02:00
|
|
|
log_error(_("can't open '%s': %s\n"),
|
2010-10-20 15:06:50 +00:00
|
|
|
print_fname_stdin(sigfile), gpg_strerror (rc));
|
2006-12-21 19:40:00 +00:00
|
|
|
goto leave;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
2006-12-06 10:16:50 +00:00
|
|
|
handle_progress (pfx, fp, sigfile);
|
2003-06-05 07:14:21 +00:00
|
|
|
|
2006-12-21 19:40:00 +00:00
|
|
|
if ( !opt.no_armor && use_armor_filter( fp ) )
|
|
|
|
{
|
|
|
|
afx = new_armor_context ();
|
2006-12-06 10:16:50 +00:00
|
|
|
push_armor_filter (afx, fp);
|
2006-12-21 19:40:00 +00:00
|
|
|
}
|
2003-06-05 07:14:21 +00:00
|
|
|
|
|
|
|
sl = NULL;
|
2006-04-19 11:26:11 +00:00
|
|
|
for(i=nfiles-1 ; i > 0 ; i-- )
|
2003-06-05 07:14:21 +00:00
|
|
|
add_to_strlist( &sl, files[i] );
|
2010-10-01 20:33:53 +00:00
|
|
|
rc = proc_signature_packets (ctrl, NULL, fp, sl, sigfile );
|
2003-06-05 07:14:21 +00:00
|
|
|
free_strlist(sl);
|
|
|
|
iobuf_close(fp);
|
2015-01-22 12:06:11 +01:00
|
|
|
if( (afx && afx->no_openpgp_data && rc == -1)
|
|
|
|
|| gpg_err_code (rc) == GPG_ERR_NO_DATA ) {
|
2003-06-05 07:14:21 +00:00
|
|
|
log_error(_("the signature could not be verified.\n"
|
|
|
|
"Please remember that the signature file (.sig or .asc)\n"
|
|
|
|
"should be the first file given on the command line.\n") );
|
|
|
|
rc = 0;
|
|
|
|
}
|
|
|
|
|
2006-12-21 19:40:00 +00:00
|
|
|
leave:
|
2006-12-06 10:16:50 +00:00
|
|
|
release_armor_context (afx);
|
|
|
|
release_progress_context (pfx);
|
2003-06-05 07:14:21 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-21 19:40:00 +00:00
|
|
|
|
2003-06-05 07:14:21 +00:00
|
|
|
void
|
|
|
|
print_file_status( int status, const char *name, int what )
|
|
|
|
{
|
2006-04-19 11:26:11 +00:00
|
|
|
char *p = xmalloc(strlen(name)+10);
|
2003-06-05 07:14:21 +00:00
|
|
|
sprintf(p, "%d %s", what, name );
|
|
|
|
write_status_text( status, p );
|
2006-04-19 11:26:11 +00:00
|
|
|
xfree(p);
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2010-10-01 20:33:53 +00:00
|
|
|
verify_one_file (ctrl_t ctrl, const char *name )
|
2003-06-05 07:14:21 +00:00
|
|
|
{
|
2006-04-19 11:26:11 +00:00
|
|
|
IOBUF fp;
|
2006-12-06 10:16:50 +00:00
|
|
|
armor_filter_context_t *afx = NULL;
|
2006-12-21 19:40:00 +00:00
|
|
|
progress_filter_context_t *pfx = new_progress_context ();
|
2003-06-05 07:14:21 +00:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
print_file_status( STATUS_FILE_START, name, 1 );
|
|
|
|
fp = iobuf_open(name);
|
2006-04-19 11:26:11 +00:00
|
|
|
if (fp)
|
2010-03-08 17:05:37 +00:00
|
|
|
iobuf_ioctl (fp, IOBUF_IOCTL_NO_CACHE, 1, NULL);
|
2006-04-19 11:26:11 +00:00
|
|
|
if (fp && is_secured_file (iobuf_get_fd (fp)))
|
|
|
|
{
|
|
|
|
iobuf_close (fp);
|
|
|
|
fp = NULL;
|
2010-04-01 13:24:55 +00:00
|
|
|
gpg_err_set_errno (EPERM);
|
2006-04-19 11:26:11 +00:00
|
|
|
}
|
2003-06-05 07:14:21 +00:00
|
|
|
if( !fp ) {
|
2006-09-14 16:50:33 +00:00
|
|
|
rc = gpg_error_from_syserror ();
|
2012-06-05 19:29:22 +02:00
|
|
|
log_error(_("can't open '%s': %s\n"),
|
2003-06-18 19:56:13 +00:00
|
|
|
print_fname_stdin(name), strerror (errno));
|
2003-06-05 07:14:21 +00:00
|
|
|
print_file_status( STATUS_FILE_ERROR, name, 1 );
|
2006-12-21 19:40:00 +00:00
|
|
|
goto leave;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
2006-12-06 10:16:50 +00:00
|
|
|
handle_progress (pfx, fp, name);
|
2003-06-05 07:14:21 +00:00
|
|
|
|
|
|
|
if( !opt.no_armor ) {
|
|
|
|
if( use_armor_filter( fp ) ) {
|
2006-12-06 10:16:50 +00:00
|
|
|
afx = new_armor_context ();
|
|
|
|
push_armor_filter (afx, fp);
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-01 20:33:53 +00:00
|
|
|
rc = proc_signature_packets (ctrl, NULL, fp, NULL, name );
|
2003-06-05 07:14:21 +00:00
|
|
|
iobuf_close(fp);
|
|
|
|
write_status( STATUS_FILE_DONE );
|
2006-12-21 19:40:00 +00:00
|
|
|
|
2007-05-03 04:44:12 +00:00
|
|
|
reset_literals_seen();
|
|
|
|
|
2006-12-21 19:40:00 +00:00
|
|
|
leave:
|
2006-12-06 10:16:50 +00:00
|
|
|
release_armor_context (afx);
|
|
|
|
release_progress_context (pfx);
|
2003-06-05 07:14:21 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************
|
|
|
|
* Verify each file given in the files array or read the names of the
|
|
|
|
* files from stdin.
|
|
|
|
* Note: This function can not handle detached signatures.
|
|
|
|
*/
|
|
|
|
int
|
2010-10-01 20:33:53 +00:00
|
|
|
verify_files (ctrl_t ctrl, int nfiles, char **files )
|
2003-06-05 07:14:21 +00:00
|
|
|
{
|
2020-02-10 15:32:55 +01:00
|
|
|
int i, rc;
|
|
|
|
int first_rc = 0;
|
2003-06-05 07:14:21 +00:00
|
|
|
|
|
|
|
if( !nfiles ) { /* read the filenames from stdin */
|
|
|
|
char line[2048];
|
|
|
|
unsigned int lno = 0;
|
|
|
|
|
|
|
|
while( fgets(line, DIM(line), stdin) ) {
|
|
|
|
lno++;
|
|
|
|
if( !*line || line[strlen(line)-1] != '\n' ) {
|
|
|
|
log_error(_("input line %u too long or missing LF\n"), lno );
|
2015-01-22 12:06:11 +01:00
|
|
|
return GPG_ERR_GENERAL;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
2020-02-10 15:32:55 +01:00
|
|
|
/* This code does not work on MSDOS but hwo cares there are
|
2003-06-05 07:14:21 +00:00
|
|
|
* also no script languages available. We don't strip any
|
|
|
|
* spaces, so that we can process nearly all filenames */
|
|
|
|
line[strlen(line)-1] = 0;
|
2020-02-10 15:32:55 +01:00
|
|
|
rc = verify_one_file (ctrl, line);
|
|
|
|
if (!first_rc)
|
|
|
|
first_rc = rc;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else { /* take filenames from the array */
|
|
|
|
for(i=0; i < nfiles; i++ )
|
2020-02-10 15:32:55 +01:00
|
|
|
{
|
|
|
|
rc = verify_one_file (ctrl, files[i]);
|
|
|
|
if (!first_rc)
|
|
|
|
first_rc = rc;
|
|
|
|
}
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
2020-02-10 15:32:55 +01:00
|
|
|
|
|
|
|
return first_rc;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
2006-12-21 19:40:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Perform a verify operation. To verify detached signatures, DATA_FD
|
|
|
|
shall be the descriptor of the signed data; for regular signatures
|
|
|
|
it needs to be -1. If OUT_FP is not NULL and DATA_FD is not -1 the
|
2011-02-04 12:57:53 +01:00
|
|
|
the signed material gets written that stream.
|
2006-12-21 19:40:00 +00:00
|
|
|
|
|
|
|
FIXME: OUTFP is not yet implemented.
|
|
|
|
*/
|
|
|
|
int
|
2010-03-08 18:19:21 +00:00
|
|
|
gpg_verify (ctrl_t ctrl, int sig_fd, int data_fd, estream_t out_fp)
|
2006-12-21 19:40:00 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
iobuf_t fp;
|
|
|
|
armor_filter_context_t *afx = NULL;
|
|
|
|
progress_filter_context_t *pfx = new_progress_context ();
|
|
|
|
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)ctrl;
|
|
|
|
(void)out_fp;
|
|
|
|
|
2010-03-08 18:19:21 +00:00
|
|
|
if (is_secured_file (sig_fd))
|
2006-12-21 19:40:00 +00:00
|
|
|
{
|
|
|
|
fp = NULL;
|
2010-03-08 18:19:21 +00:00
|
|
|
gpg_err_set_errno (EPERM);
|
2006-12-21 19:40:00 +00:00
|
|
|
}
|
2010-03-08 18:19:21 +00:00
|
|
|
else
|
|
|
|
fp = iobuf_fdopen_nc (sig_fd, "rb");
|
|
|
|
if (!fp)
|
2006-12-21 19:40:00 +00:00
|
|
|
{
|
|
|
|
rc = gpg_error_from_syserror ();
|
|
|
|
log_error (_("can't open fd %d: %s\n"), sig_fd, strerror (errno));
|
|
|
|
goto leave;
|
|
|
|
}
|
|
|
|
|
|
|
|
handle_progress (pfx, fp, NULL);
|
|
|
|
|
|
|
|
if ( !opt.no_armor && use_armor_filter (fp) )
|
|
|
|
{
|
|
|
|
afx = new_armor_context ();
|
|
|
|
push_armor_filter (afx, fp);
|
|
|
|
}
|
|
|
|
|
2010-10-01 20:33:53 +00:00
|
|
|
rc = proc_signature_packets_by_fd (ctrl, NULL, fp, data_fd);
|
2006-12-21 19:40:00 +00:00
|
|
|
|
|
|
|
if ( afx && afx->no_openpgp_data
|
|
|
|
&& (rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF) )
|
|
|
|
rc = gpg_error (GPG_ERR_NO_DATA);
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
leave:
|
2010-03-08 18:19:21 +00:00
|
|
|
iobuf_close (fp);
|
2006-12-21 19:40:00 +00:00
|
|
|
release_progress_context (pfx);
|
|
|
|
release_armor_context (afx);
|
|
|
|
return rc;
|
|
|
|
}
|
2023-04-05 21:32:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
is_fingerprint (const char *string)
|
|
|
|
{
|
|
|
|
int n;
|
|
|
|
|
|
|
|
if (!string || !*string)
|
|
|
|
return 0;
|
|
|
|
for (n=0; hexdigitp (string); string++)
|
|
|
|
n++;
|
|
|
|
if (!*string && (n == 40 || n == 64))
|
|
|
|
return 1; /* v4 or v5 fingerprint. */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* This function shall be called with the main and subkey fingerprint
|
|
|
|
* iff a signature is fully valid. If the option --assert-signer is
|
|
|
|
* active it check whether the signing key matches one of the keys
|
|
|
|
* given by this option and if so, sets a global flag. */
|
|
|
|
void
|
|
|
|
check_assert_signer_list (const char *mainpkhex, const char *pkhex)
|
|
|
|
{
|
|
|
|
gpg_error_t err;
|
|
|
|
strlist_t item;
|
|
|
|
const char *fname;
|
|
|
|
estream_t fp = NULL;
|
|
|
|
int lnr;
|
|
|
|
int n, c;
|
|
|
|
char *p, *pend;
|
|
|
|
char line[256];
|
|
|
|
|
|
|
|
if (!opt.assert_signer_list)
|
|
|
|
return; /* Nothing to do. */
|
|
|
|
if (assert_signer_true)
|
|
|
|
return; /* Already one valid signature seen. */
|
|
|
|
|
|
|
|
for (item = opt.assert_signer_list; item; item = item->next)
|
|
|
|
{
|
|
|
|
if (is_fingerprint (item->d))
|
|
|
|
{
|
|
|
|
ascii_strupr (item->d);
|
|
|
|
if (!strcmp (item->d, mainpkhex) || !strcmp (item->d, pkhex))
|
|
|
|
{
|
|
|
|
assert_signer_true = 1;
|
|
|
|
write_status_text (STATUS_ASSERT_SIGNER, item->d);
|
|
|
|
if (!opt.quiet)
|
2024-02-10 14:24:50 +01:00
|
|
|
log_info ("asserted signer '%s'\n", item->d);
|
2023-04-05 21:32:23 +02:00
|
|
|
goto leave;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Assume this is a file - read and compare. */
|
|
|
|
{
|
|
|
|
fname = item->d;
|
|
|
|
es_fclose (fp);
|
|
|
|
fp = es_fopen (fname, "r");
|
|
|
|
if (!fp)
|
|
|
|
{
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
log_error (_("error opening '%s': %s\n"),
|
|
|
|
fname, gpg_strerror (err));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
lnr = 0;
|
|
|
|
err = 0;
|
|
|
|
while (es_fgets (line, DIM(line)-1, fp))
|
|
|
|
{
|
|
|
|
lnr++;
|
|
|
|
|
|
|
|
n = strlen (line);
|
|
|
|
if (!n || line[n-1] != '\n')
|
|
|
|
{
|
|
|
|
/* Eat until end of line. */
|
|
|
|
while ( (c=es_getc (fp)) != EOF && c != '\n')
|
|
|
|
;
|
|
|
|
err = gpg_error (GPG_ERR_INCOMPLETE_LINE);
|
|
|
|
log_error (_("file '%s', line %d: %s\n"),
|
|
|
|
fname, lnr, gpg_strerror (err));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
line[--n] = 0; /* Chop the LF. */
|
|
|
|
if (n && line[n-1] == '\r')
|
|
|
|
line[--n] = 0; /* Chop an optional CR. */
|
|
|
|
|
|
|
|
/* Allow for empty lines and spaces */
|
|
|
|
for (p=line; spacep (p); p++)
|
|
|
|
;
|
|
|
|
if (!*p || *p == '#')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Get the first token and ignore trailing stuff. */
|
|
|
|
for (pend = p; *pend && !spacep (pend); pend++)
|
|
|
|
;
|
|
|
|
*pend = 0;
|
|
|
|
ascii_strupr (p);
|
|
|
|
|
|
|
|
if (!strcmp (p, mainpkhex) || !strcmp (p, pkhex))
|
|
|
|
{
|
|
|
|
assert_signer_true = 1;
|
|
|
|
write_status_text (STATUS_ASSERT_SIGNER, p);
|
|
|
|
if (!opt.quiet)
|
2024-02-10 14:24:50 +01:00
|
|
|
log_info ("asserted signer '%s' (%s:%d)\n",
|
2023-04-05 21:32:23 +02:00
|
|
|
p, fname, lnr);
|
|
|
|
goto leave;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!err && !es_feof (fp))
|
|
|
|
{
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
log_error (_("error reading '%s', line %d: %s\n"),
|
|
|
|
fname, lnr, gpg_strerror (err));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
leave:
|
|
|
|
es_fclose (fp);
|
|
|
|
}
|
2024-02-10 14:24:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* This function shall be called with the signer's public key
|
|
|
|
* algorithm ALGOSTR iff a signature is fully valid. If the option
|
|
|
|
* --assert-pubkey-algo is active the functions checks whether the
|
|
|
|
* signing key's algo is valid according to that list; in this case a
|
|
|
|
* global flag is set. */
|
|
|
|
void
|
|
|
|
check_assert_pubkey_algo (const char *algostr, const char *pkhex)
|
|
|
|
{
|
|
|
|
if (!opt.assert_pubkey_algos)
|
|
|
|
return; /* Nothing to do. */
|
|
|
|
|
|
|
|
if (compare_pubkey_string (algostr, opt.assert_pubkey_algos))
|
|
|
|
{
|
|
|
|
write_status_strings (STATUS_ASSERT_PUBKEY_ALGO,
|
|
|
|
pkhex, " 1 ", algostr, NULL);
|
|
|
|
if (!opt.quiet)
|
|
|
|
log_info ("asserted signer '%s' with algo %s\n", pkhex, algostr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!opt.quiet)
|
|
|
|
log_info ("denied signer '%s' with algo %s\n", pkhex, algostr);
|
|
|
|
assert_pubkey_algo_false = 1;
|
|
|
|
write_status_strings (STATUS_ASSERT_PUBKEY_ALGO,
|
|
|
|
pkhex, " 0 ", algostr, NULL);
|
|
|
|
}
|
|
|
|
}
|