core,cpp: Extend the TOFU information.
* src/gpgme.h.in (struct _gpeme_tofu_info): Rename FIRSTSEEN to SIGNFIRST and LASTSEEN to SIGNLAST. Add ENCRFIST and ENCRLAST. * src/keylist.c (parse_tfs_record): Parse to ENCRFIRST and ENCRLAST. * src/verify.c (parse_tofu_stats): Ditto. * tests/run-keylist.c (main): Adjust and print encrypt stats. * tests/run-verify.c (print_result): Ditto. * lang/cpp/src/tofuinfo.h (TofuInfo): Rename firstSeen to signFirst and lastSeen to signLast. Add encrCount, encrFirst and encrLast. * lang/cpp/src/tofuinfo.cpp (encrCount, encrFirst, encrLast): New. -- The latest GnuPG commits have the needed changes but we also allow the use of currently released GnuPG version. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
151da95470
commit
120b14783c
@ -123,14 +123,29 @@ unsigned short GpgME::TofuInfo::signCount() const
|
|||||||
return isNull() ? 0 : d->mInfo->signcount;
|
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)
|
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 validity: " << info.validity()
|
||||||
<< "\n policy: " << info.policy()
|
<< "\n policy: " << info.policy()
|
||||||
<< "\n signcount: "<< info.signCount()
|
<< "\n signcount: "<< info.signCount()
|
||||||
<< "\n firstseen: "<< info.firstSeen()
|
<< "\n signfirst: "<< info.signFirst()
|
||||||
<< "\n lastseen: " << info.lastSeen()
|
<< "\n signlast: " << info.signLast()
|
||||||
|
<< "\n encrcount: "<< info.encrCount()
|
||||||
|
<< "\n encrfirst: "<< info.encrFirst()
|
||||||
|
<< "\n encrlast: " << info.encrLast()
|
||||||
<< '\n';
|
<< '\n';
|
||||||
}
|
}
|
||||||
return os << ")";
|
return os << ")";
|
||||||
|
@ -93,11 +93,20 @@ public:
|
|||||||
/* Number of signatures seen for this binding. Capped at USHRT_MAX. */
|
/* Number of signatures seen for this binding. Capped at USHRT_MAX. */
|
||||||
unsigned short signCount() const;
|
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 */
|
/** 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 */
|
/** 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. */
|
/* If non-NULL a human readable string summarizing the TOFU data. */
|
||||||
const char *description() const;
|
const char *description() const;
|
||||||
|
@ -650,9 +650,11 @@ struct _gpgme_tofu_info
|
|||||||
unsigned short encrcount;
|
unsigned short encrcount;
|
||||||
|
|
||||||
/* Number of seconds since Epoch when the first and the most
|
/* Number of seconds since Epoch when the first and the most
|
||||||
* recently seen message were verified. 0 means unknown. */
|
* recently seen message were verified/decrypted. 0 means unknown. */
|
||||||
unsigned long firstseen;
|
unsigned long signfirst;
|
||||||
unsigned long lastseen;
|
unsigned long signlast;
|
||||||
|
unsigned long encrfirst;
|
||||||
|
unsigned long encrlast;
|
||||||
|
|
||||||
/* If non-NULL a human readable string summarizing the TOFU data. */
|
/* If non-NULL a human readable string summarizing the TOFU data. */
|
||||||
char *description;
|
char *description;
|
||||||
|
@ -466,11 +466,25 @@ parse_tfs_record (gpgme_user_id_t uid, char **field, int nfield)
|
|||||||
err = _gpgme_strtoul_field (field[6], &uval);
|
err = _gpgme_strtoul_field (field[6], &uval);
|
||||||
if (err)
|
if (err)
|
||||||
goto inv_engine;
|
goto inv_engine;
|
||||||
ti->firstseen = uval;
|
ti->signfirst = uval;
|
||||||
err = _gpgme_strtoul_field (field[7], &uval);
|
err = _gpgme_strtoul_field (field[7], &uval);
|
||||||
if (err)
|
if (err)
|
||||||
goto inv_engine;
|
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. */
|
/* Ready. */
|
||||||
uid->tofu = ti;
|
uid->tofu = ti;
|
||||||
|
24
src/verify.c
24
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.
|
/* 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
|
static gpgme_error_t
|
||||||
parse_tofu_stats (gpgme_signature_t sig, char *args)
|
parse_tofu_stats (gpgme_signature_t sig, char *args)
|
||||||
{
|
{
|
||||||
gpgme_error_t err;
|
gpgme_error_t err;
|
||||||
gpgme_tofu_info_t ti;
|
gpgme_tofu_info_t ti;
|
||||||
char *field[6];
|
char *field[8];
|
||||||
int nfields;
|
int nfields;
|
||||||
unsigned long uval;
|
unsigned long uval;
|
||||||
|
|
||||||
if (!sig->key || !sig->key->_last_uid || !(ti = sig->key->_last_uid->tofu))
|
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. */
|
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. */
|
return trace_gpg_error (GPG_ERR_INV_ENGINE); /* Already set. */
|
||||||
|
|
||||||
nfields = _gpgme_split_fields (args, field, DIM (field));
|
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);
|
err = _gpgme_strtoul_field (field[4], &uval);
|
||||||
if (err)
|
if (err)
|
||||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
||||||
ti->firstseen = uval;
|
ti->signfirst = uval;
|
||||||
err = _gpgme_strtoul_field (field[5], &uval);
|
err = _gpgme_strtoul_field (field[5], &uval);
|
||||||
if (err)
|
if (err)
|
||||||
return trace_gpg_error (GPG_ERR_INV_ENGINE);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -291,9 +291,11 @@ main (int argc, char **argv)
|
|||||||
ti->policy == GPGME_TOFU_POLICY_BAD? "bad" :
|
ti->policy == GPGME_TOFU_POLICY_BAD? "bad" :
|
||||||
ti->policy == GPGME_TOFU_POLICY_ASK? "ask" : "?");
|
ti->policy == GPGME_TOFU_POLICY_ASK? "ask" : "?");
|
||||||
printf (" nsigs: %hu\n", ti->signcount);
|
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 (" nencr: %hu\n", ti->encrcount);
|
||||||
printf (" first: %s\n", isotimestr (ti->firstseen));
|
printf (" first: %s\n", isotimestr (ti->encrfirst));
|
||||||
printf (" last: %s\n", isotimestr (ti->lastseen));
|
printf (" last: %s\n", isotimestr (ti->encrlast));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,9 +197,12 @@ print_result (gpgme_verify_result_t result)
|
|||||||
ti->policy == GPGME_TOFU_POLICY_UNKNOWN? "unknown" :
|
ti->policy == GPGME_TOFU_POLICY_UNKNOWN? "unknown" :
|
||||||
ti->policy == GPGME_TOFU_POLICY_BAD? "bad" :
|
ti->policy == GPGME_TOFU_POLICY_BAD? "bad" :
|
||||||
ti->policy == GPGME_TOFU_POLICY_ASK? "ask" : "?");
|
ti->policy == GPGME_TOFU_POLICY_ASK? "ask" : "?");
|
||||||
printf (" sigcount : %hu\n", ti->signcount);
|
printf (" signcount: %hu\n", ti->signcount);
|
||||||
printf (" firstseen: %s\n", isotimestr (ti->firstseen));
|
printf (" first..: %s\n", isotimestr (ti->signfirst));
|
||||||
printf (" lastseen : %s\n", isotimestr (ti->lastseen));
|
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 ....: ");
|
printf (" desc ....: ");
|
||||||
print_description (nonnull (ti->description), 15);
|
print_description (nonnull (ti->description), 15);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user