aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lang/cpp/src/tofuinfo.cpp30
-rw-r--r--lang/cpp/src/tofuinfo.h13
-rw-r--r--src/gpgme.h.in8
-rw-r--r--src/keylist.c18
-rw-r--r--src/verify.c24
-rw-r--r--tests/run-keylist.c6
-rw-r--r--tests/run-verify.c9
7 files changed, 85 insertions, 23 deletions
diff --git a/lang/cpp/src/tofuinfo.cpp b/lang/cpp/src/tofuinfo.cpp
index ade262bb..bb67fc8c 100644
--- a/lang/cpp/src/tofuinfo.cpp
+++ b/lang/cpp/src/tofuinfo.cpp
@@ -123,14 +123,29 @@ unsigned short GpgME::TofuInfo::signCount() const
return isNull() ? 0 : d->mInfo->signcount;
}
-unsigned long GpgME::TofuInfo::firstSeen() const
+unsigned short GpgME::TofuInfo::encrCount() const
{
- return isNull() ? 0 : d->mInfo->firstseen;
+ return isNull() ? 0 : d->mInfo->encrcount;
}
-unsigned long GpgME::TofuInfo::lastSeen() const
+unsigned long GpgME::TofuInfo::signFirst() const
{
- return isNull() ? 0 : d->mInfo->lastseen;
+ return isNull() ? 0 : d->mInfo->signfirst;
+}
+
+unsigned long GpgME::TofuInfo::signLast() const
+{
+ return isNull() ? 0 : d->mInfo->signlast;
+}
+
+unsigned long GpgME::TofuInfo::encrFirst() const
+{
+ return isNull() ? 0 : d->mInfo->encrfirst;
+}
+
+unsigned long GpgME::TofuInfo::encrLast() const
+{
+ return isNull() ? 0 : d->mInfo->encrlast;
}
std::ostream &GpgME::operator<<(std::ostream &os, const GpgME::TofuInfo &info)
@@ -141,8 +156,11 @@ std::ostream &GpgME::operator<<(std::ostream &os, const GpgME::TofuInfo &info)
<< "\n validity: " << info.validity()
<< "\n policy: " << info.policy()
<< "\n signcount: "<< info.signCount()
- << "\n firstseen: "<< info.firstSeen()
- << "\n lastseen: " << info.lastSeen()
+ << "\n signfirst: "<< info.signFirst()
+ << "\n signlast: " << info.signLast()
+ << "\n encrcount: "<< info.encrCount()
+ << "\n encrfirst: "<< info.encrFirst()
+ << "\n encrlast: " << info.encrLast()
<< '\n';
}
return os << ")";
diff --git a/lang/cpp/src/tofuinfo.h b/lang/cpp/src/tofuinfo.h
index eb5dbcc5..ec253e96 100644
--- a/lang/cpp/src/tofuinfo.h
+++ b/lang/cpp/src/tofuinfo.h
@@ -93,11 +93,20 @@ public:
/* Number of signatures seen for this binding. Capped at USHRT_MAX. */
unsigned short signCount() const;
+ /* Number of encryption done to this binding. Capped at USHRT_MAX. */
+ unsigned short encrCount() const;
+
/** Number of seconds since epoch when the first message was verified */
- unsigned long firstSeen() const;
+ unsigned long signFirst() const;
/** Number of seconds since epoch when the last message was verified */
- unsigned long lastSeen() const;
+ unsigned long signLast() const;
+
+ /** Number of seconds since epoch when the first message was encrypted */
+ unsigned long encrFirst() const;
+
+ /** Number of seconds since epoch when the last message was encrypted */
+ unsigned long encrLast() const;
/* If non-NULL a human readable string summarizing the TOFU data. */
const char *description() const;
diff --git a/src/gpgme.h.in b/src/gpgme.h.in
index 57f34469..00a4bed3 100644
--- a/src/gpgme.h.in
+++ b/src/gpgme.h.in
@@ -650,9 +650,11 @@ struct _gpgme_tofu_info
unsigned short encrcount;
/* Number of seconds since Epoch when the first and the most
- * recently seen message were verified. 0 means unknown. */
- unsigned long firstseen;
- unsigned long lastseen;
+ * recently seen message were verified/decrypted. 0 means unknown. */
+ unsigned long signfirst;
+ unsigned long signlast;
+ unsigned long encrfirst;
+ unsigned long encrlast;
/* If non-NULL a human readable string summarizing the TOFU data. */
char *description;
diff --git a/src/keylist.c b/src/keylist.c
index 9f1e68db..f7912e6b 100644
--- a/src/keylist.c
+++ b/src/keylist.c
@@ -466,11 +466,25 @@ parse_tfs_record (gpgme_user_id_t uid, char **field, int nfield)
err = _gpgme_strtoul_field (field[6], &uval);
if (err)
goto inv_engine;
- ti->firstseen = uval;
+ ti->signfirst = uval;
err = _gpgme_strtoul_field (field[7], &uval);
if (err)
goto inv_engine;
- ti->lastseen = uval;
+ ti->signlast = uval;
+
+ if (nfield > 9)
+ {
+ /* This condition is only to allow for gpg 2.1.15 - can
+ * eventually be removed. */
+ err = _gpgme_strtoul_field (field[8], &uval);
+ if (err)
+ goto inv_engine;
+ ti->encrfirst = uval;
+ err = _gpgme_strtoul_field (field[9], &uval);
+ if (err)
+ goto inv_engine;
+ ti->encrlast = uval;
+ }
/* Ready. */
uid->tofu = ti;
diff --git a/src/verify.c b/src/verify.c
index 92eb3334..5ac937d9 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -755,20 +755,21 @@ parse_tofu_user (gpgme_signature_t sig, char *args, gpgme_protocol_t protocol)
/* Parse a TOFU_STATS line and store it in the last tofu info of SIG.
*
- * TOFU_STATS <validity> <sign-count> <encr-count> [<policy> [<tm1> <tm2>]]
+ * TOFU_STATS <validity> <sign-count> <encr-count> \
+ * [<policy> [<tm1> <tm2> <tm3> <tm4>]]
*/
static gpgme_error_t
parse_tofu_stats (gpgme_signature_t sig, char *args)
{
gpgme_error_t err;
gpgme_tofu_info_t ti;
- char *field[6];
+ char *field[8];
int nfields;
unsigned long uval;
if (!sig->key || !sig->key->_last_uid || !(ti = sig->key->_last_uid->tofu))
return trace_gpg_error (GPG_ERR_INV_ENGINE); /* No TOFU_USER seen. */
- if (ti->firstseen || ti->signcount || ti->validity || ti->policy)
+ if (ti->signfirst || ti->signcount || ti->validity || ti->policy)
return trace_gpg_error (GPG_ERR_INV_ENGINE); /* Already set. */
nfields = _gpgme_split_fields (args, field, DIM (field));
@@ -824,11 +825,24 @@ parse_tofu_stats (gpgme_signature_t sig, char *args)
err = _gpgme_strtoul_field (field[4], &uval);
if (err)
return trace_gpg_error (GPG_ERR_INV_ENGINE);
- ti->firstseen = uval;
+ ti->signfirst = uval;
err = _gpgme_strtoul_field (field[5], &uval);
if (err)
return trace_gpg_error (GPG_ERR_INV_ENGINE);
- ti->lastseen = uval;
+ ti->signlast = uval;
+ if (nfields > 7)
+ {
+ /* This condition is only to allow for gpg 2.1.15 - can
+ * eventually be removed. */
+ err = _gpgme_strtoul_field (field[6], &uval);
+ if (err)
+ return trace_gpg_error (GPG_ERR_INV_ENGINE);
+ ti->encrfirst = uval;
+ err = _gpgme_strtoul_field (field[7], &uval);
+ if (err)
+ return trace_gpg_error (GPG_ERR_INV_ENGINE);
+ ti->encrlast = uval;
+ }
return 0;
}
diff --git a/tests/run-keylist.c b/tests/run-keylist.c
index 00f874da..647a9ed2 100644
--- a/tests/run-keylist.c
+++ b/tests/run-keylist.c
@@ -291,9 +291,11 @@ main (int argc, char **argv)
ti->policy == GPGME_TOFU_POLICY_BAD? "bad" :
ti->policy == GPGME_TOFU_POLICY_ASK? "ask" : "?");
printf (" nsigs: %hu\n", ti->signcount);
+ printf (" first: %s\n", isotimestr (ti->signfirst));
+ printf (" last: %s\n", isotimestr (ti->signlast));
printf (" nencr: %hu\n", ti->encrcount);
- printf (" first: %s\n", isotimestr (ti->firstseen));
- printf (" last: %s\n", isotimestr (ti->lastseen));
+ printf (" first: %s\n", isotimestr (ti->encrfirst));
+ printf (" last: %s\n", isotimestr (ti->encrlast));
}
}
diff --git a/tests/run-verify.c b/tests/run-verify.c
index 3c18d3b6..ebc20d97 100644
--- a/tests/run-verify.c
+++ b/tests/run-verify.c
@@ -197,9 +197,12 @@ print_result (gpgme_verify_result_t result)
ti->policy == GPGME_TOFU_POLICY_UNKNOWN? "unknown" :
ti->policy == GPGME_TOFU_POLICY_BAD? "bad" :
ti->policy == GPGME_TOFU_POLICY_ASK? "ask" : "?");
- printf (" sigcount : %hu\n", ti->signcount);
- printf (" firstseen: %s\n", isotimestr (ti->firstseen));
- printf (" lastseen : %s\n", isotimestr (ti->lastseen));
+ printf (" signcount: %hu\n", ti->signcount);
+ printf (" first..: %s\n", isotimestr (ti->signfirst));
+ printf (" last ..: %s\n", isotimestr (ti->signlast));
+ printf (" encrcount: %hu\n", ti->encrcount);
+ printf (" first..: %s\n", isotimestr (ti->encrfirst));
+ printf (" last ..: %s\n", isotimestr (ti->encrlast));
printf (" desc ....: ");
print_description (nonnull (ti->description), 15);
}