From e36b2d1bce4bb6281e18f53d06d7831e6d6f5a09 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 4 Sep 2023 17:03:01 +0200 Subject: New mode to list a v5 fingerprint for v4 packets. * src/gpgme.h.in (GPGME_KEYLIST_MODE_WITH_V5FPR): New. (struct _gpgme_subkey): Add field v5fpr. * src/engine-gpg.c (gpg_keylist_build_options): Pass new option to gpg. * src/key.c (gpgme_key_unref): Free new field. * src/keylist.c (op_data_t): Parse and add "fp2" line. * tests/run-keylist.c (show_usage): Add option --v5fpr. * src/keylist.c (op_data_t): Add field failure_code. (keylist_status_handler): Handle special value. (gpgme_op_keylist_end): Return an error if a FAILURE line has been seen. -- Note that the failure code part has been added to better diagnose problems if a wrong gpg version is used. If verything works right we should not get this because we check that the gnupg version sis either >= 2.4.4 or less than 2.3 and >= 2.2.42. Note further that the v5fpr field may also be used to get the SHA-256 fingerprint of X.509 certificates (even without passing the new mode flag). GnuPG-bug-id: 6705 --- src/engine-gpg.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/engine-gpg.c') diff --git a/src/engine-gpg.c b/src/engine-gpg.c index 99667c6d..8c9f62fb 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -3267,6 +3267,12 @@ gpg_keylist_build_options (engine_gpg_t gpg, int secret_only, err = add_arg (gpg, "--with-fingerprint"); } + if (!err && (mode & GPGME_KEYLIST_MODE_WITH_V5FPR) + && (have_gpg_version (gpg, "2.4.4") + || (have_gpg_version (gpg, "2.2.42") + && !have_gpg_version (gpg, "2.3.0")))) + err = add_arg (gpg, "--with-v5-fingerprint"); + if (!err && (mode & GPGME_KEYLIST_MODE_WITH_TOFU) && have_gpg_version (gpg, "2.1.16")) err = add_arg (gpg, "--with-tofu-info"); -- cgit v1.2.3