aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
Diffstat (limited to 'g10')
-rw-r--r--g10/Makefile.am11
-rw-r--r--g10/gpg.c9
-rw-r--r--g10/keyedit.c2
-rw-r--r--g10/keylist.c2
-rw-r--r--g10/tofu.h2
-rw-r--r--g10/trustdb.c13
6 files changed, 34 insertions, 5 deletions
diff --git a/g10/Makefile.am b/g10/Makefile.am
index 73578435d..75ccac85f 100644
--- a/g10/Makefile.am
+++ b/g10/Makefile.am
@@ -56,6 +56,12 @@ else
trust_source = trustdb.c trustdb.h tdbdump.c tdbio.c tdbio.h
endif
+if USE_TOFU
+tofu_source = tofu.h tofu.c
+else
+tofu_source =
+endif
+
if HAVE_W32_SYSTEM
resource_objs += gpg-w32info.o
@@ -124,10 +130,9 @@ gpg2_SOURCES = gpg.c \
call-dirmngr.c call-dirmngr.h \
photoid.c photoid.h \
call-agent.c call-agent.h \
- trust.c $(trust_source) \
+ trust.c $(trust_source) $(tofu_source) \
$(card_source) \
- exec.c exec.h \
- tofu.h tofu.c
+ exec.c exec.h
gpgv2_SOURCES = gpgv.c \
$(common_source) \
diff --git a/g10/gpg.c b/g10/gpg.c
index 794d5ea56..ff6e59f60 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -1949,10 +1949,12 @@ parse_trust_model(const char *model)
opt.trust_model=TM_ALWAYS;
else if(ascii_strcasecmp(model,"direct")==0)
opt.trust_model=TM_DIRECT;
+#ifdef USE_TOFU
else if(ascii_strcasecmp(model,"tofu")==0)
opt.trust_model=TM_TOFU;
else if(ascii_strcasecmp(model,"tofu+pgp")==0)
opt.trust_model=TM_TOFU_PGP;
+#endif /*USE_TOFU*/
else if(ascii_strcasecmp(model,"auto")==0)
opt.trust_model=TM_AUTO;
else
@@ -1963,6 +1965,7 @@ parse_trust_model(const char *model)
static int
parse_tofu_policy (const char *policy)
{
+#ifdef USE_TOFU
if (ascii_strcasecmp (policy, "auto") == 0)
return TOFU_POLICY_AUTO;
else if (ascii_strcasecmp (policy, "good") == 0)
@@ -1974,6 +1977,7 @@ parse_tofu_policy (const char *policy)
else if (ascii_strcasecmp (policy, "ask") == 0)
return TOFU_POLICY_ASK;
else
+#endif /*USE_TOFU*/
{
log_error (_("unknown TOFU policy '%s'\n"), policy);
g10_exit (1);
@@ -1983,6 +1987,7 @@ parse_tofu_policy (const char *policy)
static int
parse_tofu_db_format (const char *db_format)
{
+#ifdef USE_TOFU
if (ascii_strcasecmp (db_format, "auto") == 0)
return TOFU_DB_AUTO;
else if (ascii_strcasecmp (db_format, "split") == 0)
@@ -1990,6 +1995,7 @@ parse_tofu_db_format (const char *db_format)
else if (ascii_strcasecmp (db_format, "flat") == 0)
return TOFU_DB_FLAT;
else
+#endif /*USE_TOFU*/
{
log_error (_("unknown TOFU DB format '%s'\n"), db_format);
g10_exit (1);
@@ -4417,6 +4423,7 @@ main (int argc, char **argv)
break;
case aTOFUPolicy:
+#ifdef USE_TOFU
{
int policy;
int i;
@@ -4487,7 +4494,6 @@ main (int argc, char **argv)
}
merge_keys_and_selfsig (kb);
-
if (tofu_set_policy (kb, policy))
g10_exit (1);
}
@@ -4495,6 +4501,7 @@ main (int argc, char **argv)
keydb_release (hd);
}
+#endif /*USE_TOFU*/
break;
case aListPackets:
diff --git a/g10/keyedit.c b/g10/keyedit.c
index 432ba8663..fba7d3552 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -2930,10 +2930,12 @@ show_key_with_all_names_colon (ctrl_t ctrl, estream_t fp, kbnode_t keyblock)
es_putc (':', fp);
if (opt.trust_model == TM_TOFU || opt.trust_model == TM_TOFU_PGP)
{
+#ifdef USE_TOFU
enum tofu_policy policy;
if (! tofu_get_policy (primary, uid, &policy)
&& policy != TOFU_POLICY_NONE)
es_fprintf (fp, "%s", tofu_policy_str (policy));
+#endif /*USE_TOFU*/
}
es_putc (':', fp);
es_putc ('\n', fp);
diff --git a/g10/keylist.c b/g10/keylist.c
index 154169718..2a766a140 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -1501,10 +1501,12 @@ list_keyblock_colon (KBNODE keyblock, int secret, int has_secret, int fpr)
es_fprintf (es_stdout, "::::::::");
if (opt.trust_model == TM_TOFU || opt.trust_model == TM_TOFU_PGP)
{
+#ifdef USE_TOFU
enum tofu_policy policy;
if (! tofu_get_policy (pk, uid, &policy)
&& policy != TOFU_POLICY_NONE)
es_fprintf (es_stdout, "%s", tofu_policy_str (policy));
+#endif /*USE_TOFU*/
}
es_putc (':', es_stdout);
es_putc ('\n', es_stdout);
diff --git a/g10/tofu.h b/g10/tofu.h
index b0fcc5bc0..adf87abe6 100644
--- a/g10/tofu.h
+++ b/g10/tofu.h
@@ -106,4 +106,4 @@ gpg_error_t tofu_set_policy_by_keyid (u32 *keyid, enum tofu_policy policy);
gpg_error_t tofu_get_policy (PKT_public_key *pk, PKT_user_id *user_id,
enum tofu_policy *policy);
-#endif
+#endif /*G10_TOFU_H*/
diff --git a/g10/trustdb.c b/g10/trustdb.c
index f58051a75..cadc7e96b 100644
--- a/g10/trustdb.c
+++ b/g10/trustdb.c
@@ -1001,6 +1001,7 @@ tdb_get_validity_core (PKT_public_key *pk, PKT_user_id *uid,
goto leave;
}
+#ifdef USE_TOFU
if (opt.trust_model == TM_TOFU || opt.trust_model == TM_TOFU_PGP)
{
kbnode_t user_id_node = NULL; /* Silence -Wmaybe-uninitialized. */
@@ -1078,6 +1079,7 @@ tdb_get_validity_core (PKT_public_key *pk, PKT_user_id *uid,
break;
}
}
+#endif /*USE_TOFU*/
if (opt.trust_model == TM_TOFU_PGP
|| opt.trust_model == TM_CLASSIC
@@ -1137,7 +1139,18 @@ tdb_get_validity_core (PKT_public_key *pk, PKT_user_id *uid,
}
leave:
+#ifdef USE_TOFU
validity = tofu_wot_trust_combine (tofu_validity, validity);
+#else /*!USE_TOFU*/
+ validity &= TRUST_MASK;
+
+ if (validity == TRUST_NEVER)
+ /* TRUST_NEVER trumps everything else. */
+ validity |= TRUST_NEVER;
+ if (validity == TRUST_EXPIRED)
+ /* TRUST_EXPIRED trumps everything but TRUST_NEVER. */
+ validity |= TRUST_EXPIRED;
+#endif /*!USE_TOFU*/
if (opt.trust_model != TM_TOFU
&& pending_check_trustdb)