2003-06-05 07:14:21 +00:00
|
|
|
/* gpgv.c - The GnuPG signature verify utility
|
2012-01-19 22:33:51 -05:00
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2006,
|
|
|
|
* 2008, 2009, 2012 Free Software Foundation, Inc.
|
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
|
2007-07-04 19:49:40 +00:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2003-06-05 07:14:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <unistd.h>
|
2016-04-06 11:34:11 +02:00
|
|
|
#ifdef HAVE_DOSISH_SYSTEM
|
|
|
|
#include <fcntl.h> /* for setmode() */
|
|
|
|
#endif
|
2006-04-19 11:26:11 +00:00
|
|
|
#ifdef HAVE_LIBREADLINE
|
2006-09-21 13:30:45 +00:00
|
|
|
#define GNUPG_LIBREADLINE_H_INCLUDED
|
2006-04-19 11:26:11 +00:00
|
|
|
#include <readline/readline.h>
|
|
|
|
#endif
|
2003-06-05 07:14:21 +00:00
|
|
|
|
|
|
|
#define INCLUDED_BY_MAIN_MODULE 1
|
2003-06-18 19:56:13 +00:00
|
|
|
#include "gpg.h"
|
2010-10-01 20:33:53 +00:00
|
|
|
#include "util.h"
|
2003-06-05 07:14:21 +00:00
|
|
|
#include "packet.h"
|
|
|
|
#include "iobuf.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "options.h"
|
|
|
|
#include "keydb.h"
|
|
|
|
#include "trustdb.h"
|
|
|
|
#include "filter.h"
|
|
|
|
#include "ttyio.h"
|
|
|
|
#include "i18n.h"
|
2007-06-26 13:48:44 +00:00
|
|
|
#include "sysutils.h"
|
2003-06-05 07:14:21 +00:00
|
|
|
#include "status.h"
|
2006-08-16 10:47:53 +00:00
|
|
|
#include "call-agent.h"
|
2012-02-06 20:50:47 +01:00
|
|
|
#include "../common/init.h"
|
2003-06-05 07:14:21 +00:00
|
|
|
|
|
|
|
|
2008-11-13 12:37:45 +00:00
|
|
|
enum cmd_and_opt_values {
|
|
|
|
aNull = 0,
|
|
|
|
oQuiet = 'q',
|
|
|
|
oVerbose = 'v',
|
|
|
|
oBatch = 500,
|
|
|
|
oKeyring,
|
2011-02-04 12:57:53 +01:00
|
|
|
oIgnoreTimeConflict,
|
2008-11-13 12:37:45 +00:00
|
|
|
oStatusFD,
|
|
|
|
oLoggerFD,
|
|
|
|
oHomedir,
|
2015-10-18 17:35:32 -04:00
|
|
|
oWeakDigest,
|
2008-11-13 12:37:45 +00:00
|
|
|
aTest
|
|
|
|
};
|
2003-06-05 07:14:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
static ARGPARSE_OPTS opts[] = {
|
2008-11-13 12:37:45 +00:00
|
|
|
ARGPARSE_group (300, N_("@\nOptions:\n ")),
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2008-11-13 12:37:45 +00:00
|
|
|
ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")),
|
|
|
|
ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")),
|
2011-02-04 12:57:53 +01:00
|
|
|
ARGPARSE_s_s (oKeyring, "keyring",
|
2008-11-13 12:37:45 +00:00
|
|
|
N_("|FILE|take the keys from the keyring FILE")),
|
|
|
|
ARGPARSE_s_n (oIgnoreTimeConflict, "ignore-time-conflict",
|
|
|
|
N_("make timestamp conflicts only a warning")),
|
|
|
|
ARGPARSE_s_i (oStatusFD, "status-fd",
|
|
|
|
N_("|FD|write status info to this FD")),
|
|
|
|
ARGPARSE_s_i (oLoggerFD, "logger-fd", "@"),
|
|
|
|
ARGPARSE_s_s (oHomedir, "homedir", "@"),
|
2016-05-18 17:00:03 +02:00
|
|
|
ARGPARSE_s_s (oWeakDigest, "weak-digest",
|
|
|
|
N_("|ALGO|reject signatures made with ALGO")),
|
2003-06-05 07:14:21 +00:00
|
|
|
|
2008-11-13 12:37:45 +00:00
|
|
|
ARGPARSE_end ()
|
|
|
|
};
|
2003-06-05 07:14:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int g10_errors_seen = 0;
|
|
|
|
|
2008-11-13 12:37:45 +00:00
|
|
|
|
2008-11-18 18:01:03 +00:00
|
|
|
static char *
|
|
|
|
make_libversion (const char *libname, const char *(*getfnc)(const char*))
|
|
|
|
{
|
|
|
|
const char *s;
|
|
|
|
char *result;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2008-11-18 18:01:03 +00:00
|
|
|
s = getfnc (NULL);
|
|
|
|
result = xmalloc (strlen (libname) + 1 + strlen (s) + 1);
|
|
|
|
strcpy (stpcpy (stpcpy (result, libname), " "), s);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2003-06-18 19:56:13 +00:00
|
|
|
static const char *
|
|
|
|
my_strusage( int level )
|
2003-06-05 07:14:21 +00:00
|
|
|
{
|
2008-11-18 18:01:03 +00:00
|
|
|
static char *ver_gcry;
|
2008-11-13 12:37:45 +00:00
|
|
|
const char *p;
|
2008-11-18 18:01:03 +00:00
|
|
|
|
2008-11-13 12:37:45 +00:00
|
|
|
switch (level)
|
|
|
|
{
|
2013-11-18 14:09:47 +01:00
|
|
|
case 11: p = "@GPG@v (GnuPG)";
|
2008-11-13 12:37:45 +00:00
|
|
|
break;
|
|
|
|
case 13: p = VERSION; break;
|
|
|
|
case 17: p = PRINTABLE_OS_NAME; break;
|
2009-07-21 14:21:05 +00:00
|
|
|
case 19: p = _("Please report bugs to <@EMAIL@>.\n"); break;
|
|
|
|
|
2008-11-13 12:37:45 +00:00
|
|
|
case 1:
|
2009-03-17 12:13:32 +00:00
|
|
|
case 40: p = _("Usage: gpgv [options] [files] (-h for help)");
|
2008-11-13 12:37:45 +00:00
|
|
|
break;
|
2009-03-17 12:13:32 +00:00
|
|
|
case 41: p = _("Syntax: gpgv [options] [files]\n"
|
2008-11-13 12:37:45 +00:00
|
|
|
"Check signatures against known trusted keys\n");
|
2003-06-05 07:14:21 +00:00
|
|
|
break;
|
|
|
|
|
2008-11-18 18:01:03 +00:00
|
|
|
case 20:
|
|
|
|
if (!ver_gcry)
|
|
|
|
ver_gcry = make_libversion ("libgcrypt", gcry_check_version);
|
|
|
|
p = ver_gcry;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2008-11-13 12:37:45 +00:00
|
|
|
default: p = NULL;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
2008-11-13 12:37:45 +00:00
|
|
|
return p;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-19 11:26:11 +00:00
|
|
|
|
2003-06-05 07:14:21 +00:00
|
|
|
int
|
|
|
|
main( int argc, char **argv )
|
|
|
|
{
|
2008-11-13 12:37:45 +00:00
|
|
|
ARGPARSE_ARGS pargs;
|
|
|
|
int rc=0;
|
|
|
|
strlist_t sl;
|
2010-10-01 20:33:53 +00:00
|
|
|
strlist_t nrings = NULL;
|
2008-11-13 12:37:45 +00:00
|
|
|
unsigned configlineno;
|
2010-10-01 20:33:53 +00:00
|
|
|
ctrl_t ctrl;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2015-01-28 19:57:22 +01:00
|
|
|
early_system_init ();
|
2008-11-13 12:37:45 +00:00
|
|
|
set_strusage (my_strusage);
|
Call log_set_prefix() with human-readable labels.
* agent/preset-passphrase.c, agent/protect-tool.c, dirmngr/dirmngr.c
* dirmngr/t-http.c, g10/gpg.c, g10/gpgv.c, g13/g13-syshelp.c
* g13/g13.c, kbx/kbxutil.c, scd/scdaemon.c, sm/gpgsm.c
* tests/gpgscm/main.c, tools/gpg-check-pattern.c
* tools/gpg-connect-agent.c, tools/gpgconf.c, tools/gpgtar.c
* tools/symcryptrun.c: Invoke log_set_prefix() with
human-readable labels.
--
Some invocations of log_set_prefix() were done with raw numeric values
instead of values that humans can understand. Use symbolic
representations instead of numeric for better readability.
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-08-12 01:37:57 -04:00
|
|
|
log_set_prefix ("gpgv", GPGRT_LOG_WITH_PREFIX);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2008-11-13 12:37:45 +00:00
|
|
|
/* Make sure that our subsystems are ready. */
|
2008-12-09 08:58:02 +00:00
|
|
|
i18n_init();
|
2010-03-22 12:46:05 +00:00
|
|
|
init_common_subsystems (&argc, &argv);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2013-08-19 11:22:11 +02:00
|
|
|
gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
|
|
|
|
|
2008-11-13 12:37:45 +00:00
|
|
|
gnupg_init_signals (0, NULL);
|
|
|
|
|
|
|
|
opt.command_fd = -1; /* no command fd */
|
2013-08-19 11:22:11 +02:00
|
|
|
opt.keyserver_options.options |= KEYSERVER_AUTO_KEY_RETRIEVE;
|
2008-11-13 12:37:45 +00:00
|
|
|
opt.trust_model = TM_ALWAYS;
|
2016-07-09 10:20:02 +09:00
|
|
|
opt.no_sig_cache = 1;
|
|
|
|
opt.flags.require_cross_cert = 1;
|
2008-11-13 12:37:45 +00:00
|
|
|
opt.batch = 1;
|
|
|
|
|
2015-10-23 17:46:57 -04:00
|
|
|
opt.weak_digests = NULL;
|
2008-11-13 12:37:45 +00:00
|
|
|
|
|
|
|
tty_no_terminal(1);
|
|
|
|
tty_batchmode(1);
|
2011-09-23 14:43:58 +02:00
|
|
|
dotlock_disable ();
|
2013-08-19 11:22:11 +02:00
|
|
|
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
|
2015-10-23 17:46:57 -04:00
|
|
|
additional_weak_digest("MD5");
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2008-11-13 12:37:45 +00:00
|
|
|
pargs.argc = &argc;
|
|
|
|
pargs.argv = &argv;
|
|
|
|
pargs.flags= 1; /* do not remove the args */
|
|
|
|
while (optfile_parse( NULL, NULL, &configlineno, &pargs, opts))
|
|
|
|
{
|
|
|
|
switch (pargs.r_opt)
|
|
|
|
{
|
|
|
|
case oQuiet: opt.quiet = 1; break;
|
2011-02-04 12:57:53 +01:00
|
|
|
case oVerbose:
|
|
|
|
opt.verbose++;
|
2008-11-13 12:37:45 +00:00
|
|
|
opt.list_sigs=1;
|
|
|
|
gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
|
|
|
|
break;
|
|
|
|
case oKeyring: append_to_strlist( &nrings, pargs.r.ret_str); break;
|
|
|
|
case oStatusFD: set_status_fd( pargs.r.ret_int ); break;
|
2011-02-04 12:57:53 +01:00
|
|
|
case oLoggerFD:
|
2008-11-13 12:37:45 +00:00
|
|
|
log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1));
|
|
|
|
break;
|
2016-06-07 10:59:46 +02:00
|
|
|
case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break;
|
2015-10-18 17:35:32 -04:00
|
|
|
case oWeakDigest:
|
|
|
|
additional_weak_digest(pargs.r.ret_str);
|
|
|
|
break;
|
2008-11-13 12:37:45 +00:00
|
|
|
case oIgnoreTimeConflict: opt.ignore_time_conflict = 1; break;
|
|
|
|
default : pargs.err = ARGPARSE_PRINT_ERROR; break;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2008-11-13 12:37:45 +00:00
|
|
|
if (log_get_errorcount (0))
|
|
|
|
g10_exit(2);
|
|
|
|
|
|
|
|
if (opt.verbose > 1)
|
|
|
|
set_packet_list_mode(1);
|
2009-04-03 10:34:22 +00:00
|
|
|
|
2012-12-27 15:04:29 +01:00
|
|
|
/* Note: We open all keyrings in read-only mode. */
|
2009-04-03 10:34:22 +00:00
|
|
|
if (!nrings) /* No keyring given: use default one. */
|
2015-08-07 15:53:56 +02:00
|
|
|
keydb_add_resource ("trustedkeys" EXTSEP_S "kbx",
|
|
|
|
(KEYDB_RESOURCE_FLAG_READONLY
|
|
|
|
|KEYDB_RESOURCE_FLAG_GPGVDEF));
|
2008-11-13 12:37:45 +00:00
|
|
|
for (sl = nrings; sl; sl = sl->next)
|
2016-04-06 11:34:11 +02:00
|
|
|
keydb_add_resource (sl->d, KEYDB_RESOURCE_FLAG_READONLY);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2008-11-13 12:37:45 +00:00
|
|
|
FREE_STRLIST (nrings);
|
2010-10-01 20:33:53 +00:00
|
|
|
|
|
|
|
ctrl = xcalloc (1, sizeof *ctrl);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2010-10-01 20:33:53 +00:00
|
|
|
if ((rc = verify_signatures (ctrl, argc, argv)))
|
2015-01-22 12:06:11 +01:00
|
|
|
log_error("verify signatures failed: %s\n", gpg_strerror (rc) );
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2010-10-01 20:33:53 +00:00
|
|
|
xfree (ctrl);
|
|
|
|
|
2008-11-13 12:37:45 +00:00
|
|
|
/* cleanup */
|
|
|
|
g10_exit (0);
|
|
|
|
return 8; /*NOTREACHED*/
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
g10_exit( int rc )
|
|
|
|
{
|
2008-11-13 12:37:45 +00:00
|
|
|
rc = rc? rc : log_get_errorcount(0)? 2 : g10_errors_seen? 1 : 0;
|
|
|
|
exit(rc );
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Stub:
|
2015-11-16 12:41:46 +01:00
|
|
|
* We have to override the trustcheck from pkclist.c because
|
2003-06-05 07:14:21 +00:00
|
|
|
* this utility assumes that all keys in the keyring are trustworthy
|
|
|
|
*/
|
|
|
|
int
|
2016-05-21 11:41:49 +02:00
|
|
|
check_signatures_trust (ctrl_t ctrl, PKT_signature *sig)
|
2003-06-05 07:14:21 +00:00
|
|
|
{
|
2016-05-21 11:41:49 +02:00
|
|
|
(void)ctrl;
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)sig;
|
|
|
|
return 0;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
|
2006-04-19 11:26:11 +00:00
|
|
|
void
|
2008-10-20 13:53:23 +00:00
|
|
|
read_trust_options(byte *trust_model, ulong *created, ulong *nextcheck,
|
2012-01-19 22:33:51 -05:00
|
|
|
byte *marginals, byte *completes, byte *cert_depth,
|
|
|
|
byte *min_cert_level)
|
2008-10-20 13:53:23 +00:00
|
|
|
{
|
|
|
|
(void)trust_model;
|
|
|
|
(void)created;
|
|
|
|
(void)nextcheck;
|
|
|
|
(void)marginals;
|
|
|
|
(void)completes;
|
|
|
|
(void)cert_depth;
|
2012-01-19 22:33:51 -05:00
|
|
|
(void)min_cert_level;
|
2008-10-20 13:53:23 +00:00
|
|
|
}
|
2003-06-05 07:14:21 +00:00
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
/* Stub:
|
2003-06-05 07:14:21 +00:00
|
|
|
* We don't have the trustdb , so we have to provide some stub functions
|
|
|
|
* instead
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
cache_disabled_value(PKT_public_key *pk)
|
|
|
|
{
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)pk;
|
2003-06-05 07:14:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-19 11:26:11 +00:00
|
|
|
void
|
2016-05-21 11:41:49 +02:00
|
|
|
check_trustdb_stale (ctrl_t ctrl)
|
2008-10-20 13:53:23 +00:00
|
|
|
{
|
2016-05-21 11:41:49 +02:00
|
|
|
(void)ctrl;
|
2008-10-20 13:53:23 +00:00
|
|
|
}
|
2006-04-19 11:26:11 +00:00
|
|
|
|
2003-06-05 07:14:21 +00:00
|
|
|
int
|
2016-05-21 11:41:49 +02:00
|
|
|
get_validity_info (ctrl_t ctrl, PKT_public_key *pk, PKT_user_id *uid)
|
2003-06-05 07:14:21 +00:00
|
|
|
{
|
2016-05-21 11:41:49 +02:00
|
|
|
(void)ctrl;
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)pk;
|
|
|
|
(void)uid;
|
|
|
|
return '?';
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
2016-05-21 11:41:49 +02:00
|
|
|
get_validity (ctrl_t ctrl, PKT_public_key *pk, PKT_user_id *uid,
|
|
|
|
PKT_signature *sig, int may_ask)
|
2003-06-05 07:14:21 +00:00
|
|
|
{
|
2016-05-21 11:41:49 +02:00
|
|
|
(void)ctrl;
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)pk;
|
|
|
|
(void)uid;
|
g10: Add TOFU support.
* configure.ac: Check for sqlite3.
(SQLITE3_CFLAGS): AC_SUBST it.
(SQLITE3_LIBS): Likewise.
* g10/Makefile.am (AM_CFLAGS): Add $(SQLITE3_CFLAGS).
(gpg2_SOURCES): Add tofu.h and tofu.c.
(gpg2_LDADD): Add $(SQLITE3_LIBS).
* g10/tofu.c: New file.
* g10/tofu.h: New file.
* g10/options.h (trust_model): Define TM_TOFU and TM_TOFU_PGP.
(tofu_db_format): Define.
* g10/packet.h (PKT_signature): Add fields digest and digest_len.
* g10/gpg.c: Include "tofu.h".
(cmd_and_opt_values): Declare aTOFUPolicy, oTOFUDefaultPolicy,
oTOFUDBFormat.
(opts): Add them.
(parse_trust_model): Recognize the tofu and tofu+pgp trust models.
(parse_tofu_policy): New function.
(parse_tofu_db_format): New function.
(main): Initialize opt.tofu_default_policy and opt.tofu_db_format.
Handle aTOFUPolicy, oTOFUDefaultPolicy and oTOFUDBFormat.
* g10/mainproc.c (do_check_sig): If the signature is good, copy the
hash to SIG->DIGEST and set SIG->DIGEST_LEN appropriately.
* g10/trustdb.h (get_validity): Add arguments sig and may_ask. Update
callers.
(tdb_get_validity_core): Add arguments sig and may_ask. Update
callers.
* g10/trust.c (get_validity) Add arguments sig and may_ask. Pass them
to tdb_get_validity_core.
* g10/trustdb.c: Include "tofu.h".
(trust_model_string): Handle TM_TOFU and TM_TOFU_PGP.
(tdb_get_validity_core): Add arguments sig and may_ask. If
OPT.TRUST_MODEL is TM_TOFU or TM_TOFU_PGP, compute the TOFU trust
level. Combine it with the computed PGP trust level, if appropriate.
* g10/keyedit.c: Include "tofu.h".
(show_key_with_all_names_colon): If the trust mode is tofu or
tofu+pgp, then show the trust policy.
* g10/keylist.c: Include "tofu.h".
(public_key_list): Also show the PGP stats if the trust model is
TM_TOFU_PGP.
(list_keyblock_colon): If the trust mode is tofu or
tofu+pgp, then show the trust policy.
* g10/pkclist.c: Include "tofu.h".
* g10/gpgv.c (get_validity): Add arguments sig and may_ask.
(enum tofu_policy): Define.
(tofu_get_policy): New stub.
(tofu_policy_str): Likewise.
* g10/test-stubs.c (get_validity): Add arguments sig and may_ask.
(enum tofu_policy): Define.
(tofu_get_policy): New stub.
(tofu_policy_str): Likewise.
* doc/DETAILS: Describe the TOFU Policy field.
* doc/gpg.texi: Document --tofu-set-policy, --trust-model=tofu,
--trust-model=tofu+pgp, --tofu-default-policy and --tofu-db-format.
* tests/openpgp/Makefile.am (TESTS): Add tofu.test.
(TEST_FILES): Add tofu-keys.asc, tofu-keys-secret.asc,
tofu-2183839A-1.txt, tofu-BC15C85A-1.txt and tofu-EE37CF96-1.txt.
(CLEANFILES): Add tofu.db.
(clean-local): Add tofu.d.
* tests/openpgp/tofu.test: New file.
* tests/openpgp/tofu-2183839A-1.txt: New file.
* tests/openpgp/tofu-BC15C85A-1.txt: New file.
* tests/openpgp/tofu-EE37CF96-1.txt: New file.
* tests/openpgp/tofu-keys.asc: New file.
* tests/openpgp/tofu-keys-secret.asc: New file.
--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-10-18 18:44:05 +02:00
|
|
|
(void)sig;
|
|
|
|
(void)may_ask;
|
2003-06-05 07:14:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
trust_value_to_string (unsigned int value)
|
|
|
|
{
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)value;
|
2003-06-05 07:14:21 +00:00
|
|
|
return "err";
|
|
|
|
}
|
|
|
|
|
2006-04-19 11:26:11 +00:00
|
|
|
const char *
|
2016-05-21 11:41:49 +02:00
|
|
|
uid_trust_string_fixed (ctrl_t ctrl, PKT_public_key *key, PKT_user_id *uid)
|
2006-04-19 11:26:11 +00:00
|
|
|
{
|
2016-05-21 11:41:49 +02:00
|
|
|
(void)ctrl;
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)key;
|
|
|
|
(void)uid;
|
2006-04-19 11:26:11 +00:00
|
|
|
return "err";
|
|
|
|
}
|
|
|
|
|
2003-06-05 07:14:21 +00:00
|
|
|
int
|
|
|
|
get_ownertrust_info (PKT_public_key *pk)
|
|
|
|
{
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)pk;
|
|
|
|
return '?';
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
get_ownertrust (PKT_public_key *pk)
|
|
|
|
{
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)pk;
|
|
|
|
return TRUST_UNKNOWN;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-19 11:26:11 +00:00
|
|
|
/* Stubs:
|
2003-06-05 07:14:21 +00:00
|
|
|
* Because we only work with trusted keys, it does not make sense to
|
|
|
|
* get them from a keyserver
|
|
|
|
*/
|
2006-04-19 11:26:11 +00:00
|
|
|
|
|
|
|
struct keyserver_spec *
|
2008-10-20 13:53:23 +00:00
|
|
|
keyserver_match (struct keyserver_spec *spec)
|
|
|
|
{
|
|
|
|
(void)spec;
|
2011-02-04 12:57:53 +01:00
|
|
|
return NULL;
|
2008-10-20 13:53:23 +00:00
|
|
|
}
|
2006-04-19 11:26:11 +00:00
|
|
|
|
2016-01-21 11:49:27 +01:00
|
|
|
int
|
|
|
|
keyserver_any_configured (ctrl_t ctrl)
|
|
|
|
{
|
|
|
|
(void)ctrl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-06-05 07:14:21 +00:00
|
|
|
int
|
2008-10-20 13:53:23 +00:00
|
|
|
keyserver_import_keyid (u32 *keyid, void *dummy)
|
2003-06-05 07:14:21 +00:00
|
|
|
{
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)keyid;
|
|
|
|
(void)dummy;
|
|
|
|
return -1;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
|
2016-06-20 23:58:16 +02:00
|
|
|
int
|
|
|
|
keyserver_import_fprint (ctrl_t ctrl, const byte *fprint,size_t fprint_len,
|
|
|
|
struct keyserver_spec *keyserver)
|
|
|
|
{
|
|
|
|
(void)ctrl;
|
|
|
|
(void)fprint;
|
|
|
|
(void)fprint_len;
|
|
|
|
(void)keyserver;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-04-19 11:26:11 +00:00
|
|
|
int
|
2008-10-20 13:53:23 +00:00
|
|
|
keyserver_import_cert (const char *name)
|
|
|
|
{
|
|
|
|
(void)name;
|
2011-02-04 12:57:53 +01:00
|
|
|
return -1;
|
2008-10-20 13:53:23 +00:00
|
|
|
}
|
2006-04-19 11:26:11 +00:00
|
|
|
|
|
|
|
int
|
2008-10-20 13:53:23 +00:00
|
|
|
keyserver_import_pka (const char *name,unsigned char *fpr)
|
|
|
|
{
|
|
|
|
(void)name;
|
|
|
|
(void)fpr;
|
|
|
|
return -1;
|
|
|
|
}
|
2006-04-19 11:26:11 +00:00
|
|
|
|
2016-04-27 08:34:29 +02:00
|
|
|
gpg_error_t
|
|
|
|
keyserver_import_wkd (ctrl_t ctrl, const char *name,
|
|
|
|
unsigned char **fpr, size_t *fpr_len)
|
|
|
|
{
|
|
|
|
(void)ctrl;
|
|
|
|
(void)name;
|
|
|
|
(void)fpr;
|
|
|
|
(void)fpr_len;
|
|
|
|
return GPG_ERR_BUG;
|
|
|
|
}
|
|
|
|
|
2006-04-19 11:26:11 +00:00
|
|
|
int
|
2008-10-20 13:53:23 +00:00
|
|
|
keyserver_import_name (const char *name,struct keyserver_spec *spec)
|
2006-04-19 11:26:11 +00:00
|
|
|
{
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)name;
|
|
|
|
(void)spec;
|
2006-04-19 11:26:11 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2008-10-20 13:53:23 +00:00
|
|
|
keyserver_import_ldap (const char *name)
|
|
|
|
{
|
|
|
|
(void)name;
|
|
|
|
return -1;
|
|
|
|
}
|
2006-04-19 11:26:11 +00:00
|
|
|
|
2016-07-06 14:03:50 +02:00
|
|
|
|
|
|
|
gpg_error_t
|
|
|
|
read_key_from_file (ctrl_t ctrl, const char *fname, kbnode_t *r_keyblock)
|
|
|
|
{
|
|
|
|
(void)ctrl;
|
|
|
|
(void)fname;
|
|
|
|
(void)r_keyblock;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-05 07:14:21 +00:00
|
|
|
/* Stub:
|
|
|
|
* No encryption here but mainproc links to these functions.
|
|
|
|
*/
|
2010-04-21 17:30:07 +00:00
|
|
|
gpg_error_t
|
2015-11-03 23:15:27 +01:00
|
|
|
get_session_key (ctrl_t ctrl, PKT_pubkey_enc *k, DEK *dek)
|
2003-06-05 07:14:21 +00:00
|
|
|
{
|
2015-11-03 23:15:27 +01:00
|
|
|
(void)ctrl;
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)k;
|
|
|
|
(void)dek;
|
2015-01-22 12:06:11 +01:00
|
|
|
return GPG_ERR_GENERAL;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
2008-10-20 13:53:23 +00:00
|
|
|
|
2003-06-05 07:14:21 +00:00
|
|
|
/* Stub: */
|
2010-04-21 17:30:07 +00:00
|
|
|
gpg_error_t
|
2008-10-20 13:53:23 +00:00
|
|
|
get_override_session_key (DEK *dek, const char *string)
|
2003-06-05 07:14:21 +00:00
|
|
|
{
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)dek;
|
|
|
|
(void)string;
|
2015-01-22 12:06:11 +01:00
|
|
|
return GPG_ERR_GENERAL;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
2008-10-20 13:53:23 +00:00
|
|
|
|
2003-06-05 07:14:21 +00:00
|
|
|
/* Stub: */
|
|
|
|
int
|
2010-10-01 20:33:53 +00:00
|
|
|
decrypt_data (ctrl_t ctrl, void *procctx, PKT_encrypted *ed, DEK *dek)
|
2003-06-05 07:14:21 +00:00
|
|
|
{
|
2010-10-01 20:33:53 +00:00
|
|
|
(void)ctrl;
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)procctx;
|
|
|
|
(void)ed;
|
|
|
|
(void)dek;
|
2015-01-22 12:06:11 +01:00
|
|
|
return GPG_ERR_GENERAL;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Stub:
|
2008-10-20 13:53:23 +00:00
|
|
|
* No interactive commands, so we don't need the helptexts
|
2003-06-05 07:14:21 +00:00
|
|
|
*/
|
|
|
|
void
|
2008-10-20 13:53:23 +00:00
|
|
|
display_online_help (const char *keyword)
|
2003-06-05 07:14:21 +00:00
|
|
|
{
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)keyword;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Stub:
|
|
|
|
* We don't use secret keys, but getkey.c links to this
|
|
|
|
*/
|
|
|
|
int
|
2010-04-20 17:57:50 +00:00
|
|
|
check_secret_key (PKT_public_key *pk, int n)
|
2003-06-05 07:14:21 +00:00
|
|
|
{
|
2010-04-20 17:57:50 +00:00
|
|
|
(void)pk;
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)n;
|
2015-01-22 12:06:11 +01:00
|
|
|
return GPG_ERR_GENERAL;
|
2003-06-05 07:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Stub:
|
2011-02-04 12:57:53 +01:00
|
|
|
* No secret key, so no passphrase needed
|
2003-06-05 07:14:21 +00:00
|
|
|
*/
|
|
|
|
DEK *
|
2016-08-08 18:45:29 +02:00
|
|
|
passphrase_to_dek (int cipher_algo, STRING2KEY *s2k, int create, int nocache,
|
2003-06-05 07:14:21 +00:00
|
|
|
const char *tmp, int *canceled)
|
|
|
|
{
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)cipher_algo;
|
|
|
|
(void)s2k;
|
2016-08-08 18:45:29 +02:00
|
|
|
(void)create;
|
|
|
|
(void)nocache;
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)tmp;
|
|
|
|
|
2003-06-05 07:14:21 +00:00
|
|
|
if (canceled)
|
|
|
|
*canceled = 0;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-08-20 08:41:15 +00:00
|
|
|
void
|
2016-08-08 18:45:29 +02:00
|
|
|
passphrase_clear_cache (const char *cacheid)
|
2009-08-20 08:41:15 +00:00
|
|
|
{
|
|
|
|
(void)cacheid;
|
|
|
|
}
|
|
|
|
|
2008-10-20 13:53:23 +00:00
|
|
|
struct keyserver_spec *
|
2011-02-04 12:57:53 +01:00
|
|
|
parse_preferred_keyserver(PKT_signature *sig)
|
2006-04-19 11:26:11 +00:00
|
|
|
{
|
2008-10-20 13:53:23 +00:00
|
|
|
(void)sig;
|
2006-04-19 11:26:11 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-10-20 13:53:23 +00:00
|
|
|
struct keyserver_spec *
|
|
|
|
parse_keyserver_uri (const char *uri, int require_scheme,
|
|
|
|
const char *configname, unsigned int configlineno)
|
|
|
|
{
|
|
|
|
(void)uri;
|
|
|
|
(void)require_scheme;
|
|
|
|
(void)configname;
|
|
|
|
(void)configlineno;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
void
|
2008-10-20 13:53:23 +00:00
|
|
|
free_keyserver_spec (struct keyserver_spec *keyserver)
|
|
|
|
{
|
|
|
|
(void)keyserver;
|
|
|
|
}
|
2006-04-19 11:26:11 +00:00
|
|
|
|
2003-06-05 07:14:21 +00:00
|
|
|
/* Stubs to avoid linking to photoid.c */
|
2011-02-04 12:57:53 +01:00
|
|
|
void
|
2008-10-20 13:53:23 +00:00
|
|
|
show_photos (const struct user_attribute *attrs, int count, PKT_public_key *pk)
|
|
|
|
{
|
|
|
|
(void)attrs;
|
|
|
|
(void)count;
|
|
|
|
(void)pk;
|
|
|
|
}
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
int
|
2008-10-20 13:53:23 +00:00
|
|
|
parse_image_header (const struct user_attribute *attr, byte *type, u32 *len)
|
|
|
|
{
|
|
|
|
(void)attr;
|
|
|
|
(void)type;
|
|
|
|
(void)len;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
image_type_to_string (byte type, int string)
|
|
|
|
{
|
|
|
|
(void)type;
|
|
|
|
(void)string;
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-06-05 07:14:21 +00:00
|
|
|
|
2006-04-19 11:26:11 +00:00
|
|
|
#ifdef ENABLE_CARD_SUPPORT
|
2011-02-04 12:57:53 +01:00
|
|
|
int
|
2008-10-20 13:53:23 +00:00
|
|
|
agent_scd_getattr (const char *name, struct agent_card_info_s *info)
|
|
|
|
{
|
|
|
|
(void)name;
|
|
|
|
(void)info;
|
|
|
|
return 0;
|
|
|
|
}
|
2006-04-19 11:26:11 +00:00
|
|
|
#endif /* ENABLE_CARD_SUPPORT */
|
|
|
|
|
2008-10-20 13:53:23 +00:00
|
|
|
/* We do not do any locking, so use these stubs here */
|
2011-02-04 12:57:53 +01:00
|
|
|
void
|
2011-09-23 14:43:58 +02:00
|
|
|
dotlock_disable (void)
|
2008-10-20 13:53:23 +00:00
|
|
|
{
|
|
|
|
}
|
2003-06-05 07:14:21 +00:00
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
dotlock_t
|
2011-09-28 15:41:58 +02:00
|
|
|
dotlock_create (const char *file_to_lock, unsigned int flags)
|
2008-10-20 13:53:23 +00:00
|
|
|
{
|
|
|
|
(void)file_to_lock;
|
2011-09-28 15:41:58 +02:00
|
|
|
(void)flags;
|
2008-10-20 13:53:23 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-06-05 07:14:21 +00:00
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
void
|
2011-09-23 14:43:58 +02:00
|
|
|
dotlock_destroy (dotlock_t h)
|
2008-10-20 13:53:23 +00:00
|
|
|
{
|
|
|
|
(void)h;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2011-09-23 14:43:58 +02:00
|
|
|
dotlock_take (dotlock_t h, long timeout)
|
2008-10-20 13:53:23 +00:00
|
|
|
{
|
|
|
|
(void)h;
|
|
|
|
(void)timeout;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2011-09-23 14:43:58 +02:00
|
|
|
dotlock_release (dotlock_t h)
|
2008-10-20 13:53:23 +00:00
|
|
|
{
|
|
|
|
(void)h;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
void
|
2011-09-23 14:43:58 +02:00
|
|
|
dotlock_remove_lockfiles (void)
|
2008-10-20 13:53:23 +00:00
|
|
|
{
|
|
|
|
}
|
2003-06-05 07:14:21 +00:00
|
|
|
|
2010-04-21 16:26:17 +00:00
|
|
|
gpg_error_t
|
|
|
|
agent_probe_secret_key (ctrl_t ctrl, PKT_public_key *pk)
|
|
|
|
{
|
|
|
|
(void)ctrl;
|
|
|
|
(void)pk;
|
|
|
|
return gpg_error (GPG_ERR_NO_SECKEY);
|
|
|
|
}
|
2010-10-13 15:57:08 +00:00
|
|
|
|
|
|
|
gpg_error_t
|
|
|
|
agent_probe_any_secret_key (ctrl_t ctrl, kbnode_t keyblock)
|
|
|
|
{
|
|
|
|
(void)ctrl;
|
|
|
|
(void)keyblock;
|
|
|
|
return gpg_error (GPG_ERR_NO_SECKEY);
|
|
|
|
}
|
|
|
|
|
|
|
|
gpg_error_t
|
2016-06-10 16:15:33 -04:00
|
|
|
agent_get_keyinfo (ctrl_t ctrl, const char *hexkeygrip,
|
|
|
|
char **r_serialno, int *r_cleartext)
|
2010-10-13 15:57:08 +00:00
|
|
|
{
|
|
|
|
(void)ctrl;
|
|
|
|
(void)hexkeygrip;
|
2016-06-10 16:15:33 -04:00
|
|
|
(void)r_cleartext;
|
2010-10-13 15:57:08 +00:00
|
|
|
*r_serialno = NULL;
|
|
|
|
return gpg_error (GPG_ERR_NO_SECKEY);
|
|
|
|
}
|
2015-04-23 15:42:56 +02:00
|
|
|
|
|
|
|
gpg_error_t
|
|
|
|
gpg_dirmngr_get_pka (ctrl_t ctrl, const char *userid,
|
|
|
|
unsigned char **r_fpr, size_t *r_fprlen,
|
|
|
|
char **r_url)
|
|
|
|
{
|
|
|
|
(void)ctrl;
|
|
|
|
(void)userid;
|
|
|
|
if (r_fpr)
|
|
|
|
*r_fpr = NULL;
|
|
|
|
if (r_fprlen)
|
|
|
|
*r_fprlen = 0;
|
|
|
|
if (r_url)
|
|
|
|
*r_url = NULL;
|
|
|
|
return gpg_error (GPG_ERR_NOT_FOUND);
|
|
|
|
}
|
2015-10-08 15:04:45 +02:00
|
|
|
|
|
|
|
gpg_error_t
|
|
|
|
export_pubkey_buffer (ctrl_t ctrl, const char *keyspec, unsigned int options,
|
2015-11-12 16:02:35 +01:00
|
|
|
export_stats_t stats,
|
2015-10-08 15:04:45 +02:00
|
|
|
kbnode_t *r_keyblock, void **r_data, size_t *r_datalen)
|
|
|
|
{
|
|
|
|
(void)ctrl;
|
|
|
|
(void)keyspec;
|
|
|
|
(void)options;
|
2015-11-12 16:02:35 +01:00
|
|
|
(void)stats;
|
2015-10-08 15:04:45 +02:00
|
|
|
|
|
|
|
*r_keyblock = NULL;
|
|
|
|
*r_data = NULL;
|
|
|
|
*r_datalen = 0;
|
|
|
|
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
|
|
|
}
|
g10: Add TOFU support.
* configure.ac: Check for sqlite3.
(SQLITE3_CFLAGS): AC_SUBST it.
(SQLITE3_LIBS): Likewise.
* g10/Makefile.am (AM_CFLAGS): Add $(SQLITE3_CFLAGS).
(gpg2_SOURCES): Add tofu.h and tofu.c.
(gpg2_LDADD): Add $(SQLITE3_LIBS).
* g10/tofu.c: New file.
* g10/tofu.h: New file.
* g10/options.h (trust_model): Define TM_TOFU and TM_TOFU_PGP.
(tofu_db_format): Define.
* g10/packet.h (PKT_signature): Add fields digest and digest_len.
* g10/gpg.c: Include "tofu.h".
(cmd_and_opt_values): Declare aTOFUPolicy, oTOFUDefaultPolicy,
oTOFUDBFormat.
(opts): Add them.
(parse_trust_model): Recognize the tofu and tofu+pgp trust models.
(parse_tofu_policy): New function.
(parse_tofu_db_format): New function.
(main): Initialize opt.tofu_default_policy and opt.tofu_db_format.
Handle aTOFUPolicy, oTOFUDefaultPolicy and oTOFUDBFormat.
* g10/mainproc.c (do_check_sig): If the signature is good, copy the
hash to SIG->DIGEST and set SIG->DIGEST_LEN appropriately.
* g10/trustdb.h (get_validity): Add arguments sig and may_ask. Update
callers.
(tdb_get_validity_core): Add arguments sig and may_ask. Update
callers.
* g10/trust.c (get_validity) Add arguments sig and may_ask. Pass them
to tdb_get_validity_core.
* g10/trustdb.c: Include "tofu.h".
(trust_model_string): Handle TM_TOFU and TM_TOFU_PGP.
(tdb_get_validity_core): Add arguments sig and may_ask. If
OPT.TRUST_MODEL is TM_TOFU or TM_TOFU_PGP, compute the TOFU trust
level. Combine it with the computed PGP trust level, if appropriate.
* g10/keyedit.c: Include "tofu.h".
(show_key_with_all_names_colon): If the trust mode is tofu or
tofu+pgp, then show the trust policy.
* g10/keylist.c: Include "tofu.h".
(public_key_list): Also show the PGP stats if the trust model is
TM_TOFU_PGP.
(list_keyblock_colon): If the trust mode is tofu or
tofu+pgp, then show the trust policy.
* g10/pkclist.c: Include "tofu.h".
* g10/gpgv.c (get_validity): Add arguments sig and may_ask.
(enum tofu_policy): Define.
(tofu_get_policy): New stub.
(tofu_policy_str): Likewise.
* g10/test-stubs.c (get_validity): Add arguments sig and may_ask.
(enum tofu_policy): Define.
(tofu_get_policy): New stub.
(tofu_policy_str): Likewise.
* doc/DETAILS: Describe the TOFU Policy field.
* doc/gpg.texi: Document --tofu-set-policy, --trust-model=tofu,
--trust-model=tofu+pgp, --tofu-default-policy and --tofu-db-format.
* tests/openpgp/Makefile.am (TESTS): Add tofu.test.
(TEST_FILES): Add tofu-keys.asc, tofu-keys-secret.asc,
tofu-2183839A-1.txt, tofu-BC15C85A-1.txt and tofu-EE37CF96-1.txt.
(CLEANFILES): Add tofu.db.
(clean-local): Add tofu.d.
* tests/openpgp/tofu.test: New file.
* tests/openpgp/tofu-2183839A-1.txt: New file.
* tests/openpgp/tofu-BC15C85A-1.txt: New file.
* tests/openpgp/tofu-EE37CF96-1.txt: New file.
* tests/openpgp/tofu-keys.asc: New file.
* tests/openpgp/tofu-keys-secret.asc: New file.
--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-10-18 18:44:05 +02:00
|
|
|
|
2016-08-25 09:26:36 +02:00
|
|
|
gpg_error_t
|
|
|
|
tofu_write_tfs_record (ctrl_t ctrl, estream_t fp,
|
|
|
|
PKT_public_key *pk, const char *user_id)
|
|
|
|
{
|
|
|
|
(void)ctrl;
|
|
|
|
(void)fp;
|
|
|
|
(void)pk;
|
|
|
|
(void)user_id;
|
|
|
|
return gpg_error (GPG_ERR_GENERAL);
|
|
|
|
}
|
|
|
|
|
g10: Add TOFU support.
* configure.ac: Check for sqlite3.
(SQLITE3_CFLAGS): AC_SUBST it.
(SQLITE3_LIBS): Likewise.
* g10/Makefile.am (AM_CFLAGS): Add $(SQLITE3_CFLAGS).
(gpg2_SOURCES): Add tofu.h and tofu.c.
(gpg2_LDADD): Add $(SQLITE3_LIBS).
* g10/tofu.c: New file.
* g10/tofu.h: New file.
* g10/options.h (trust_model): Define TM_TOFU and TM_TOFU_PGP.
(tofu_db_format): Define.
* g10/packet.h (PKT_signature): Add fields digest and digest_len.
* g10/gpg.c: Include "tofu.h".
(cmd_and_opt_values): Declare aTOFUPolicy, oTOFUDefaultPolicy,
oTOFUDBFormat.
(opts): Add them.
(parse_trust_model): Recognize the tofu and tofu+pgp trust models.
(parse_tofu_policy): New function.
(parse_tofu_db_format): New function.
(main): Initialize opt.tofu_default_policy and opt.tofu_db_format.
Handle aTOFUPolicy, oTOFUDefaultPolicy and oTOFUDBFormat.
* g10/mainproc.c (do_check_sig): If the signature is good, copy the
hash to SIG->DIGEST and set SIG->DIGEST_LEN appropriately.
* g10/trustdb.h (get_validity): Add arguments sig and may_ask. Update
callers.
(tdb_get_validity_core): Add arguments sig and may_ask. Update
callers.
* g10/trust.c (get_validity) Add arguments sig and may_ask. Pass them
to tdb_get_validity_core.
* g10/trustdb.c: Include "tofu.h".
(trust_model_string): Handle TM_TOFU and TM_TOFU_PGP.
(tdb_get_validity_core): Add arguments sig and may_ask. If
OPT.TRUST_MODEL is TM_TOFU or TM_TOFU_PGP, compute the TOFU trust
level. Combine it with the computed PGP trust level, if appropriate.
* g10/keyedit.c: Include "tofu.h".
(show_key_with_all_names_colon): If the trust mode is tofu or
tofu+pgp, then show the trust policy.
* g10/keylist.c: Include "tofu.h".
(public_key_list): Also show the PGP stats if the trust model is
TM_TOFU_PGP.
(list_keyblock_colon): If the trust mode is tofu or
tofu+pgp, then show the trust policy.
* g10/pkclist.c: Include "tofu.h".
* g10/gpgv.c (get_validity): Add arguments sig and may_ask.
(enum tofu_policy): Define.
(tofu_get_policy): New stub.
(tofu_policy_str): Likewise.
* g10/test-stubs.c (get_validity): Add arguments sig and may_ask.
(enum tofu_policy): Define.
(tofu_get_policy): New stub.
(tofu_policy_str): Likewise.
* doc/DETAILS: Describe the TOFU Policy field.
* doc/gpg.texi: Document --tofu-set-policy, --trust-model=tofu,
--trust-model=tofu+pgp, --tofu-default-policy and --tofu-db-format.
* tests/openpgp/Makefile.am (TESTS): Add tofu.test.
(TEST_FILES): Add tofu-keys.asc, tofu-keys-secret.asc,
tofu-2183839A-1.txt, tofu-BC15C85A-1.txt and tofu-EE37CF96-1.txt.
(CLEANFILES): Add tofu.db.
(clean-local): Add tofu.d.
* tests/openpgp/tofu.test: New file.
* tests/openpgp/tofu-2183839A-1.txt: New file.
* tests/openpgp/tofu-BC15C85A-1.txt: New file.
* tests/openpgp/tofu-EE37CF96-1.txt: New file.
* tests/openpgp/tofu-keys.asc: New file.
* tests/openpgp/tofu-keys-secret.asc: New file.
--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-10-18 18:44:05 +02:00
|
|
|
gpg_error_t
|
2016-05-21 12:26:44 +02:00
|
|
|
tofu_get_policy (ctrl_t ctrl, PKT_public_key *pk, PKT_user_id *user_id,
|
g10: Add TOFU support.
* configure.ac: Check for sqlite3.
(SQLITE3_CFLAGS): AC_SUBST it.
(SQLITE3_LIBS): Likewise.
* g10/Makefile.am (AM_CFLAGS): Add $(SQLITE3_CFLAGS).
(gpg2_SOURCES): Add tofu.h and tofu.c.
(gpg2_LDADD): Add $(SQLITE3_LIBS).
* g10/tofu.c: New file.
* g10/tofu.h: New file.
* g10/options.h (trust_model): Define TM_TOFU and TM_TOFU_PGP.
(tofu_db_format): Define.
* g10/packet.h (PKT_signature): Add fields digest and digest_len.
* g10/gpg.c: Include "tofu.h".
(cmd_and_opt_values): Declare aTOFUPolicy, oTOFUDefaultPolicy,
oTOFUDBFormat.
(opts): Add them.
(parse_trust_model): Recognize the tofu and tofu+pgp trust models.
(parse_tofu_policy): New function.
(parse_tofu_db_format): New function.
(main): Initialize opt.tofu_default_policy and opt.tofu_db_format.
Handle aTOFUPolicy, oTOFUDefaultPolicy and oTOFUDBFormat.
* g10/mainproc.c (do_check_sig): If the signature is good, copy the
hash to SIG->DIGEST and set SIG->DIGEST_LEN appropriately.
* g10/trustdb.h (get_validity): Add arguments sig and may_ask. Update
callers.
(tdb_get_validity_core): Add arguments sig and may_ask. Update
callers.
* g10/trust.c (get_validity) Add arguments sig and may_ask. Pass them
to tdb_get_validity_core.
* g10/trustdb.c: Include "tofu.h".
(trust_model_string): Handle TM_TOFU and TM_TOFU_PGP.
(tdb_get_validity_core): Add arguments sig and may_ask. If
OPT.TRUST_MODEL is TM_TOFU or TM_TOFU_PGP, compute the TOFU trust
level. Combine it with the computed PGP trust level, if appropriate.
* g10/keyedit.c: Include "tofu.h".
(show_key_with_all_names_colon): If the trust mode is tofu or
tofu+pgp, then show the trust policy.
* g10/keylist.c: Include "tofu.h".
(public_key_list): Also show the PGP stats if the trust model is
TM_TOFU_PGP.
(list_keyblock_colon): If the trust mode is tofu or
tofu+pgp, then show the trust policy.
* g10/pkclist.c: Include "tofu.h".
* g10/gpgv.c (get_validity): Add arguments sig and may_ask.
(enum tofu_policy): Define.
(tofu_get_policy): New stub.
(tofu_policy_str): Likewise.
* g10/test-stubs.c (get_validity): Add arguments sig and may_ask.
(enum tofu_policy): Define.
(tofu_get_policy): New stub.
(tofu_policy_str): Likewise.
* doc/DETAILS: Describe the TOFU Policy field.
* doc/gpg.texi: Document --tofu-set-policy, --trust-model=tofu,
--trust-model=tofu+pgp, --tofu-default-policy and --tofu-db-format.
* tests/openpgp/Makefile.am (TESTS): Add tofu.test.
(TEST_FILES): Add tofu-keys.asc, tofu-keys-secret.asc,
tofu-2183839A-1.txt, tofu-BC15C85A-1.txt and tofu-EE37CF96-1.txt.
(CLEANFILES): Add tofu.db.
(clean-local): Add tofu.d.
* tests/openpgp/tofu.test: New file.
* tests/openpgp/tofu-2183839A-1.txt: New file.
* tests/openpgp/tofu-BC15C85A-1.txt: New file.
* tests/openpgp/tofu-EE37CF96-1.txt: New file.
* tests/openpgp/tofu-keys.asc: New file.
* tests/openpgp/tofu-keys-secret.asc: New file.
--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-10-18 18:44:05 +02:00
|
|
|
enum tofu_policy *policy)
|
|
|
|
{
|
2016-05-21 12:26:44 +02:00
|
|
|
(void)ctrl;
|
g10: Add TOFU support.
* configure.ac: Check for sqlite3.
(SQLITE3_CFLAGS): AC_SUBST it.
(SQLITE3_LIBS): Likewise.
* g10/Makefile.am (AM_CFLAGS): Add $(SQLITE3_CFLAGS).
(gpg2_SOURCES): Add tofu.h and tofu.c.
(gpg2_LDADD): Add $(SQLITE3_LIBS).
* g10/tofu.c: New file.
* g10/tofu.h: New file.
* g10/options.h (trust_model): Define TM_TOFU and TM_TOFU_PGP.
(tofu_db_format): Define.
* g10/packet.h (PKT_signature): Add fields digest and digest_len.
* g10/gpg.c: Include "tofu.h".
(cmd_and_opt_values): Declare aTOFUPolicy, oTOFUDefaultPolicy,
oTOFUDBFormat.
(opts): Add them.
(parse_trust_model): Recognize the tofu and tofu+pgp trust models.
(parse_tofu_policy): New function.
(parse_tofu_db_format): New function.
(main): Initialize opt.tofu_default_policy and opt.tofu_db_format.
Handle aTOFUPolicy, oTOFUDefaultPolicy and oTOFUDBFormat.
* g10/mainproc.c (do_check_sig): If the signature is good, copy the
hash to SIG->DIGEST and set SIG->DIGEST_LEN appropriately.
* g10/trustdb.h (get_validity): Add arguments sig and may_ask. Update
callers.
(tdb_get_validity_core): Add arguments sig and may_ask. Update
callers.
* g10/trust.c (get_validity) Add arguments sig and may_ask. Pass them
to tdb_get_validity_core.
* g10/trustdb.c: Include "tofu.h".
(trust_model_string): Handle TM_TOFU and TM_TOFU_PGP.
(tdb_get_validity_core): Add arguments sig and may_ask. If
OPT.TRUST_MODEL is TM_TOFU or TM_TOFU_PGP, compute the TOFU trust
level. Combine it with the computed PGP trust level, if appropriate.
* g10/keyedit.c: Include "tofu.h".
(show_key_with_all_names_colon): If the trust mode is tofu or
tofu+pgp, then show the trust policy.
* g10/keylist.c: Include "tofu.h".
(public_key_list): Also show the PGP stats if the trust model is
TM_TOFU_PGP.
(list_keyblock_colon): If the trust mode is tofu or
tofu+pgp, then show the trust policy.
* g10/pkclist.c: Include "tofu.h".
* g10/gpgv.c (get_validity): Add arguments sig and may_ask.
(enum tofu_policy): Define.
(tofu_get_policy): New stub.
(tofu_policy_str): Likewise.
* g10/test-stubs.c (get_validity): Add arguments sig and may_ask.
(enum tofu_policy): Define.
(tofu_get_policy): New stub.
(tofu_policy_str): Likewise.
* doc/DETAILS: Describe the TOFU Policy field.
* doc/gpg.texi: Document --tofu-set-policy, --trust-model=tofu,
--trust-model=tofu+pgp, --tofu-default-policy and --tofu-db-format.
* tests/openpgp/Makefile.am (TESTS): Add tofu.test.
(TEST_FILES): Add tofu-keys.asc, tofu-keys-secret.asc,
tofu-2183839A-1.txt, tofu-BC15C85A-1.txt and tofu-EE37CF96-1.txt.
(CLEANFILES): Add tofu.db.
(clean-local): Add tofu.d.
* tests/openpgp/tofu.test: New file.
* tests/openpgp/tofu-2183839A-1.txt: New file.
* tests/openpgp/tofu-BC15C85A-1.txt: New file.
* tests/openpgp/tofu-EE37CF96-1.txt: New file.
* tests/openpgp/tofu-keys.asc: New file.
* tests/openpgp/tofu-keys-secret.asc: New file.
--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-10-18 18:44:05 +02:00
|
|
|
(void)pk;
|
|
|
|
(void)user_id;
|
|
|
|
(void)policy;
|
|
|
|
return gpg_error (GPG_ERR_GENERAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
tofu_policy_str (enum tofu_policy policy)
|
|
|
|
{
|
|
|
|
(void)policy;
|
|
|
|
|
|
|
|
return "unknown";
|
|
|
|
}
|
2015-10-23 17:23:17 +02:00
|
|
|
|
|
|
|
void
|
2016-08-05 14:40:36 +02:00
|
|
|
tofu_begin_batch_update (ctrl_t ctrl)
|
2015-10-23 17:23:17 +02:00
|
|
|
{
|
2016-08-05 14:40:36 +02:00
|
|
|
(void)ctrl;
|
2015-10-23 17:23:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-08-05 14:40:36 +02:00
|
|
|
tofu_end_batch_update (ctrl_t ctrl)
|
2015-10-23 17:23:17 +02:00
|
|
|
{
|
2016-08-05 14:40:36 +02:00
|
|
|
(void)ctrl;
|
2015-10-23 17:23:17 +02:00
|
|
|
}
|